<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.

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>

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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.