View Full Version : Help needed adding PHP variable into javascript

12-03-2012, 05:07 AM
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) ?>";


12-03-2012, 06:11 AM
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.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum