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

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Kadafiz
1

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;
Votes + Comments
really good
0

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

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.