I have a drop down list in my program that is being populated by values from mySQL and a "Submit" button. The trouble I am running into is how do I assign the selected value in the drop down to a variable?
Thanks guys!
Need help with Dropdown list
Moderator: General Moderators
- andyhoneycutt
- Forum Contributor
- Posts: 468
- Joined: Wed Aug 27, 2008 10:02 am
- Location: Idaho Falls
Re: Need help with Dropdown list
Please post the code in question (in
Code: Select all
tags).
-AndyRe: Need help with Dropdown list
Code: Select all
<tr>ect name="storenumber">
<?if(isset($store_number['store1'])){?><option value="<?=$store_number['store1'];?>"><?=$store_number['store1'];?></option><?}?>
<?if(isset($store_number['store2'])){?><option value="<?=$store_number['store2'];?>"><?=$store_number['store2'];?></option><?}?>
<?if(isset($store_number['store3'])){?><option value="<?=$store_number['store3'];?>"><?=$store_number['store3'];?></option><?}?>
</select>
<tr>
<tr>
<tr class="header">
<td colspan=2 align="center" class="header"><input type="submit" value="store"></td>
</tr>
</table>
<input type="hidden" name="store" value="2">
<?
if(isset($_REQUEST['store']))
{
$report = $_GET['storenumber'];
echo $report;
?>
- andyhoneycutt
- Forum Contributor
- Posts: 468
- Joined: Wed Aug 27, 2008 10:02 am
- Location: Idaho Falls
Re: Need help with Dropdown list
It sounds like you're asking only how to make any option selected by default in a drop-down? If that's the case:
-Andy
Code: Select all
<select name="something">
<option value="some_value" selected="selected">Blah Blah Blah</option>
<option value="other_value">Blah2 Blah2 Blah2</option>
</select>Re: Need help with Dropdown list
Never mind, I figgured it out.