...

View Full Version : Variable Passing to function



mitch@vif
06-06-2007, 07:23 PM
I have a program using java that passes two variables to the UpdateItem function but do not know how to add another variable. The java recalculates the quantity and passes this along with the unchanged itemId back to the function UpdateItem. I started adding a third item called install and would like to pass it unchanged to the UpdateItem function but could not get it to work, your assistance would be appreciated

function UpdateQty(item)
{
itemId=item.name;
install=item.install;
newQty=item.options[item.selectedIndex].text;
document.location.href='cart.php?action=update_item&id='+itemId+'&qty='+newQty;
}

function UpdateItem($itemid, $qty, $install)
{global $dbServer, $dbUser, $dbPass, $dbName;
// Get a connection to the database


<select name="<?php echo $row["itemId"]; ?>", install="<?php echo $row["install"]; ?>" onchange="UpdateQty(this)">
<?php

for($i = 1; $i <= 20; $i++)
{echo "<option ";
if($row["quant"] == $i)
{echo " SELECTED ";}
echo ">" . $i . "</option>";}?>
</select>
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);



Thanks
mitch

cyberlogi
06-07-2007, 01:05 AM
Yikes....

First, there is no Java code anywhere in your example. There is JavaScript and PHP code, both are very different from Java.

Second, your UpdateItem function is written in PHP, not in JavaScript.

Please restate your question to address these issues. I'm not sure what you are asking.

mitch@vif
06-07-2007, 02:53 AM
I would like to pass a another variable 'install' from the HTML select name through the javascript to the PHP function UpdateItem. Presently the variable 'itemId' is passed unchanged this way and 'qty' is updated for the PHP function.

Hope this helps

cyberlogi
06-07-2007, 07:32 PM
Mitch, you can't pass variables from JavaScript to PHP. That is impossible.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum