select problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
prasadharischandra
Forum Commoner
Posts: 57
Joined: Thu May 09, 2002 2:19 am
Location: sri lanka
Contact:

select problem

Post by prasadharischandra »

my code is
<select name="find" onChange="sub2()">

<option value="C">Confirmed</option>
<option value="R">Reserved</option>
<option value="A">Cancelld</option>
<option value="W">Waiting</option>

<?if ($find=='W'){

$test="<option value=\"W\" selected>Waiting</option>";
}?>
<?if ($find=='C'){

$test.="<option value=\"C\" selected>Confirmed</option>";
}?>
<?if ($find=='A'){

$test.="<option value=\"A\" selected>Cancelld</option>";
}?>
<?if ($find=='R'){

$test.="<option value=\"R\" selected>Reserved</option>";
}
echo $test;?>

</select>
my problem is if i select "cancelled" in same page it will appear "cancelled"
but in my code it will selected but two "cancelled" i want to only one cancelled and other shoul be in drop down
help me
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Post by RandomEngy »

Try this instead:

Code: Select all

<option value="C"<? if($find=='C') echo " selected" ?>>Confirmed</option> 
<option value="R"<? if($find=='R') echo " selected" ?>>Reserved</option> 
<option value="A"<? if($find=='A') echo " selected" ?>>Cancelld</option> 
<option value="W"<? if($find=='W') echo " selected" ?>>Waiting</option>
And get rid of the $test stuff. I'm guessing this is what you want, but I'm not sure what you're trying to say.
prasadharischandra
Forum Commoner
Posts: 57
Joined: Thu May 09, 2002 2:19 am
Location: sri lanka
Contact:

Re: select problem

Post by prasadharischandra »

thank u it's working
Post Reply