Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

list of allowed drop down/select values.

Status
Not open for further replies.

swathip

Programmer
Oct 10, 2009
17
US
Hi all,

The issue is i am selecting option 1 and then going to the next page and i am coming back.The option MALE is being saved.When i try to echo it,nothing is showing up.

<tr>
<td class="tdvisitbig">
<select class="selectbig" name="gender">
<?
$arr = array("1"=>"MALE", "2"=>"FEMALE");
foreach($arr as $p=>$v)
{
if($p != $gender)
{
echo "<option value='$p'>$v</option>";
}
else
{
echo "<option selected value='$p'>$v</option>";
}
}
?>
</select>
</td>
</tr>

The code which i am using to echo it is

if($gender == '1'){echo "male";}
if($gender == '2'){echo "female";}

Is there something i am missing .when i am selecting option 2 and save it and then try to echo it it prints out fine.

Thanks in advance.
 
I'm not sure I follow. So for clarification what is the flow of this.

Your submit your dropdown to another script, and then back to this one?

Where are the if($gender) conditionals? In the script it submits to or this original one?

Where and how is $gender getting set?








----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
@vacunita,

The way it works is,
the end user can select the gender along with a couple of form fields and then they can go to the next page.These pages are part of iframes.When ever they go to the next page(or go back to the prev page),the form values are saved to the database (using a php script).They always have option to go back and forth.

Thanks
Swathi
 
O.k, so again:

Where are the if($gender) conditionals? In the script it submits to or this original one?

Where and how is $gender getting set?



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
@vacunita,

I am echoing it in the same page- i mean the origianl script.the database has the values stored if i select 1 or 2,but i am having a problem only when i am echoing it.

Swathi
 
Code:
 if($p != $gender) 
    { 
     echo "<option value='$p'>$v</option>"; 
    } 
    else 
    { 
     echo "<option selected[red]=\"selected\"[/red] value='$p'>$v</option>"; 
    }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top