问题描述:

I have a sample code:

<form action="index.php" method="get">

<select name="id">

<option value="1">One</option>

<option value="2">Two</option>

</select>

<input type="submit" value="submit" name="submit" />

</form>

When I submit form is url is "index.php?id=1" // or index.php?id=2

=> How to fix it is result "index.php?id=1&name=One" // or index.php?id=2&name=Two

网友答案:

I think the best approach is to populate the options from a db. Use the values as db ID numbers. Then you can store as much info as you want for each option. example:

//some sort of loop{
<option value="
<?php echo $row_option['id'];?>">
<?php echo $row_option['display_text'];?></option> 
}

At the other end query db with value; use whatever data need with that value.

相关阅读:
Top