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>

Recommended Answers

All 3 Replies

Member Avatar for LastMitch

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.

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

Member Avatar for LastMitch

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

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.