Hey all, this is my first post and I know what I am doing wrong I am just not versed well enough in php nor javascript to find a workaround. I have the following code which makes an array based on the itemname and then populates the array with information previously received from a mysql query and this part works.
while ($row=mysql_fetch_array($result)) {
$id = $row["id"];
$itemname=$row["itemname"];
$upc=$row["UPC"];
$instock=$row["instock"];
$price=$row["price"];
$options.="<OPTION VALUE=\"$itemname\">".$itemname.'</option>';
?>
var $arrayname = <?php echo "'$itemname'" ?>;
$arrayname = new Array();
//Create array dependent on $itemname and insert data into it.
$arrayname[0] = <?php echo "'$id'" ?>;
$arrayname[1] = <?php echo "'$itemname'" ?>;
$arrayname[2] = <?php echo "'$upc'" ?>;
$arrayname[3] = <?php echo "'$instock'" ?>;
$arrayname[4] = <?php echo "'$price'" ?>;
<?php } ?>
I then have a drop down menu that contains all of the 'itemname's and therefore all the names of the arrays. However, the 'value' of the drop down menu items is not the array themselves, but merely the names and I pass the name to a javascript that will populate textboxes with correlated information. What I want to know is how can i manipulate it so that it will either pass the arrays themselves or once the name is passed to the js function have it determine that I want it to use the array and not merely the name of the array. Thanks in advance!!!
function displayInfo(itemname){
document.inventory.instock.value = itemname[3];
//Other populating stuff
}
</script>
<form action="availibility.php" name="inventory" method="POST">
Items in Inventory
<select name=itemname
onchange="displayInfo(document.inventory.itemname.value)">
<option value=0>
<?=$options?>
</option>
</select>