Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-03-2012, 05:07 AM   PM User | #1
Dreamer07
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Dreamer07 is an unknown quantity at this point
Help needed adding PHP variable into javascript

Hello, I am trying to call an image filename and the page title into a section of javascript located within a php file in the "head" section. The js is part of a shopping cart. My problem is with inserting the PHP variables between the " ". When viewing the source code of the generated page, the PHP has been ignored and it is blank between the " ".

I've been working on this for most of the day and nothing seems to work. I dont' know what to try next. I know it has something to do with php being ignored in the script type= text/javascript, but what I've found through google searches has not solved the problem. I don't understand javascript very well, but could that be a solution for calling the gallery name and filename?

Does anyone have any idea on how I can get this to work??? I appreciate any help or direction offered.

<script type="text/javascript">

<!--
function CalculateOrder(form)
{

if (document.myform.os0.value == "5x7")
{
document.myform.amount.value = 10.00;
document.myform.item_name.value = "<?= $page_title ?>";
document.myform.item_number.value = "<?= $item->title) ?>";
}

}
-->
</script>
Dreamer07 is offline   Reply With Quote
Old 12-03-2012, 06:11 AM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,452
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
What does the PHP source look like? The PHP runs before the JavaScript so the way they are combined together has to take that into account.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:31 PM.


Advertisement
Log in to turn off these ads.