0
<select name="item2" id="item2" onchange="getPrice(this.id)" />
      
      <option value="">Select medicine</option>
      <?php
$sql = "SELECT ItemID, ItemName, Price FROM itemavail ORDER BY ItemName";
$rs = mysql_query($sql);
while($row = mysql_fetch_array($rs))
{
  echo "<option value=\"".$row['Price']."\">".$row['ItemName']."</option> \n  ";
}

?>
      </select>

this is selection menu to get item name. Here i need to get Item ID according to what user select from the selection menu.
(here im already exacting Price from this selection menu. thn i cant change value of this options)
plz someone help me to get rid from this... thk u.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by vibhaJ
0

You can pass ItemID as a value.
After form submitted you can again fire select query to fetch price of selected item from ItemID.

<select name="item2" id="item2" onchange="getPrice(this.id)" />
<option value="">Select medicine</option>
<?php
	$sql = "SELECT ItemID, ItemName, Price FROM itemavail ORDER BY ItemName";
	$rs = mysql_query($sql);
	while($row = mysql_fetch_array($rs))
	{
	  echo "<option value=\"".$row['ItemID']."\">".$row['ItemName']."</option> \n  ";
	}
?>
</select>
0

You can also use below code to pass both id and price in single form.

<?
	$item2 = $_REQUEST['item2'];
	$ar = explode('###',$item2);
	$itemId = $ar[0];
	$itemPrice = $ar[1];
?>
<select name="item2" id="item2" onchange="getPrice(this.id)" />
<option value="">Select medicine</option>
<?php
	$sql = "SELECT ItemID, ItemName, Price FROM itemavail ORDER BY ItemName";
	$rs = mysql_query($sql);
	while($row = mysql_fetch_array($rs))
	{
	  echo "<option value=\"".$row['ItemID'].'###'.$row['Price']."\">".$row['ItemName']."</option> \n  ";
	}
?>
</select>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.