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
ljCharlie
Forum Contributor
Posts: 289 Joined: Wed May 19, 2004 8:23 am
Post
by ljCharlie » Mon Sep 27, 2004 10:18 am
Below is a drop down list I have in my form.
Code: Select all
<form name="frmScholarship" method="post" action="<?php $HTTP_SERVER_VARS['PHP_SELF']?>">
<select name="sltScholarship" id="sltScholarship" onChange="frmScholarship.submit()">
<?php
do {
?>
<option value="<?php echo $row_rsScholarshipType['sectionID']?>"<?php if (!(strcmp($row_rsScholarshipType['sectionID'], 100))) {echo "SELECTED";} ?>><?php echo $row_rsScholarshipType['category']?></option>
<?php
} while ($row_rsScholarshipType = mysql_fetch_assoc($rsScholarshipType));
$rows = mysql_num_rows($rsScholarshipType);
if($rows > 0) {
mysql_data_seek($rsScholarshipType, 0);
$row_rsScholarshipType = mysql_fetch_assoc($rsScholarshipType);
}
?>
</select>
</form>
The problem I have is that when a user select an option from the drop down list and the page refresh, the drop down option list that the user chose did not get selected after the page is refresh. How do I get the option selected to be selected and shown on the drop down list after the page refresh?
ljCharlie
Joe
Forum Regular
Posts: 939 Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow
Post
by Joe » Mon Sep 27, 2004 10:22 am
An easy way around this would be to "POST" the users choice and setup a simple if statement to determine which option is to be "SELECTED".
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Sep 27, 2004 10:41 am
Charlie, you've been here long enough to know that you were supposed to use
Code: Select all
tags..
look through the results of this search [devnet]+form +selected[/devnet] for lots of threads about creating selection lists.
ljCharlie
Forum Contributor
Posts: 289 Joined: Wed May 19, 2004 8:23 am
Post
by ljCharlie » Mon Sep 27, 2004 1:08 pm
Well, at first I was going to put into PHP but then I also have some code that are not PHP so that is why I didn't put in PHP. Sorry.
Anyway, I got it. It is working now.
Many thanks for your help!
ljCharlie