jay_bo Posted March 27, 2010 Share Posted March 27, 2010 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 More sharing options...
RC Posted March 28, 2010 Share Posted March 28, 2010 If I understand what you mean correctly, just use this to get the value: $value = $_POST['dropdown']; Link to comment https://forums.phpfreaks.com/topic/196714-retrieving-vaules-from-a-drop-down-menu/#findComment-1032917 Share on other sites More sharing options...
jay_bo Posted March 28, 2010 Author Share Posted March 28, 2010 If I understand what you mean correctly, just use this to get the value: $value = $_POST['dropdown']; Would that work as there is no form tag around the elements and all that code i have posted above is on the same page. Link to comment https://forums.phpfreaks.com/topic/196714-retrieving-vaules-from-a-drop-down-menu/#findComment-1032957 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.