You are here: Re: if null=true « All PHP « IT news, forums, messages
Re: if null=true

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">&pound;10,000</option>
> <option value="11000">&pound;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 "\">&pound;".$dropdowndata[$i]."</option>\n";
}
?>
<input name="Submit" type="submit" value="Submit" style="width:320">
</form>


//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация