<select name="item8" id="item8" onchange="getPrice(this.id)" />
      <option value="" >Select here</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']."\n  ";
}

?>
      </span>
    </div>
      </select>

im using this code to make selection field. Here i want to get a Item ID when selecting Item. bt i cant change that Price as the "value=" of the Option. because i need value as a price for the bill counting. here i use another text field to enter quantity of item. here i need is when user select item and enter quantity Item table should be deduct that quantity from item table quantity.. please HELp mee..

Recommended Answers

All 2 Replies

im using this code to make selection field. Here i want to get a Item ID when selecting Item. bt i cant change that Price as the "value=" of the Option. because i need value as a price for the bill counting

OK, so currently for every record you are sending something similar to: <option value="12">...</option> Why not just send something like: <option value="xxx___12">...</option> Where "xxx" is your ItemId and "___" is just a "delimiter".

echo sprintf('<option value="%s___%s">%s</option>' . PHP_EOL, $row['ItemId'], $row['Price'], $row['ItemName']);

Thus, all you would need to do when you get that value, is split the value at the delimiter:

list( $itemId, $itemValue) = explode("___",$_POST['item8']);
echo 'Item: '.$itemId . '=' . $itemValue;
commented: really good +1

heyyy... thnk you very much for your HELP... reallly Appreciate that.. !!

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.