|
Posted by J.O. Aho on 03/09/06 13:48
Steve wrote:
> its still not returning anything in the drop down menu here is my code:
>
> <form action="calc.php" method="post" enctype="multipart/form-data"
> name="form1" target="_self" id="form1">
>
> <select name="number1" id="number1">
> <?php
> if(!isnull($number1)) {
> echo "<option value='<?php echo $number1; ?>'
> selected='selected'>£<?php echo $number1; ?></option>";
> echo "<option value=''> - - - </option>";
> }
> ?>
> <option value="10000">£10,000</option>
> <option value="11000">£11,000</option>
> // etc etc
> </select>
>
> <input name="Submit" type="submit" value="Submit" style="width:320">
> </form>
>
>
> What i am trying to achieve is that if they have submitted the form it
> displays the value they have submitted at the top of the drop down menu
> as well as the existing values.
>
> If they havent then it just displays the html values in the drop down
> menu.
>
> Currently i am getting a drop down menu with nothing in it!
>
<form action="calc.php" method="post" enctype="multipart/form-data"
name="form1" id="form1">
<select name="number1" id="number1">
<?PHP
/* We create an array of data we want for the drop down */
$dropdowndata=array("10000","11000","11100","11110", "11111");
for($i=0;$i<count($dropdowndata);$i++) {
echo "<option value=\"".$dropdowndata[$i];
if(!empty($_POST['number1'] && $dropdowndata[$i]==$_POST['number1']) {
echo " selected";
}
echo "\">£".$dropdowndata[$i]."</option>\n";
}
?>
<input name="Submit" type="submit" value="Submit" style="width:320">
</form>
//Aho
Navigation:
[Reply to this message]
|