0

how to get the class value?

<select name="product" onchange="Price(this)">
    <option value="" disabled="disabled" selected="selected">Please select a product</option>
    <?php
    foreach ($product as $product) {
    ?>
    <option value="<?php echo $product['Product']?>" id="<?php echo $product['Price']?>"><?php echo $product['Product'] . " Qty: " . $product['Quantity']?></option>
    <?php
    }
    ?>
    </select>
2
Contributors
3
Replies
18
Views
4 Years
Discussion Span
Last Post by LastMitch
0

how to get the class value?

Are you connected to the database? If so was there any error when you ran the code. The only thing I notice now is that you don't have a query to fetch the data for:

  <option value="<?php echo $product['Product']?>" id="<?php echo $product['Price']?>"><?php echo $product['Product'] . " Qty: " . $product['Quantity']?></option>

You need a query to fetch those data so it can appear in the dropdown list.

0

yup i am connected in database

what i want is on dropbox change i want to get the class value and put it in the "quantity" textbox

0

what i want is on dropbox change i want to get the class value and put it in the "quantity" textbox

You need a query for this to work. There are few ways you can do this.

Since you never provide a query then try this:

<form id="form1" name="form1" method="post" action="">
<select name="product" onchange="Price(this)">
<option value="">--- Select ---</option>
<?php $sql = mysql_query("select * from mytable order by yourcolumn asc");
 while($row=mysql_fetch_assoc($sql)){ ?>
<option value="<?php echo $product['Product']?>" id="<?php echo $product['Price']?>"><?php echo $product['Product'] . " Qty: " . $product['Quantity']?></option>
<?php } ?>
</select>
<input type="submit" name="Submit" value="Select" />
</form>

It's not tested. You can read more this dropdown list here and look at these example more clearly:

http://www.kavoir.com/2009/02/php-drop-down-list.html

and this:

http://www.html-form-guide.com/php-form/php-form-select.html

Edited by LastMitch: grammer

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.