Jump to content

Retrieving vaules from a drop down menu.


jay_bo

Recommended Posts

Hi,

 

Basically i want to get the vaule from the drop down box when my add button is clicked...the code...

$cat=$_GET['cat'];
if ($cat!="")
{
		$result=mysql_query("SELECT * FROM products WHERE cat_id=$cat");
		while($row=mysql_fetch_array($result)){

echo '<br />';
echo '<div id="item_container">';
echo '<div id="item_picture"><a href="'.$row["picture_large"].'" class="thickbox" rel="album" ><img src="'.$row["picture"].'" border="0" alt="'.$row["image_alt"].'"></a></div>';
echo '<div id="item_title"><h2>'.$row["name"].'</h2></div>';
echo '<div id="item_text"><p>'.substr($row["description"], 0, 100).'</p><br /><br />';
echo '<select name="dropdown">';
echo '<option value="1">Size 9" - '.$row["price1"].'</option>';
echo '<option value="2">Size 12" - '.$row["price2"].'</option>';
echo '<option value="3">Size 14" - '.$row["price3"].'</option>';
echo '</select>';
echo '<br /><br/>';
echo '<input type="button" value="Add to Cart" onclick="addtocart('.$row["serial"].')"/></span>';
		echo '</div>';
		echo '<br />';
		echo '<br />';
echo '</div>';
}
}
else
{

}

 

Then when it is clicked it goes to this javascript code....

function addtocart(pid){
	document.form1.productid.value=pid;
	document.form1.command.value='add';
	document.form1.submit();

}

 

Which then goes to....

if($_REQUEST['command']=='add' && $_REQUEST['productid']>0){
	$pid=$_REQUEST['productid'];
	addtocart($pid,1);
	header("location:shoppingcart.php?$select");
	exit();
}

And place the drop menu value in that part of the code, as a varible ^^^

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/196714-retrieving-vaules-from-a-drop-down-menu/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.