Forum Moderators: coopster

Message Too Old, No Replies

Set variable using drop down

drop down, dropdown, set variable

         

jonk

2:06 pm on Aug 16, 2007 (gmt 0)

10+ Year Member



Drop down again.....

Using onchange, changes a variable for 'display number of entries'.

Thing is, when the page reloads to display the number of entries submitted, the dropdown shows the top option again, rather than the last chosen option - can anyone point out if there's a way to change this?

d40sithui

2:38 pm on Aug 16, 2007 (gmt 0)

10+ Year Member




rather than
<option value='something'>Value</option>

use
<option selected value='something'>Value</option>

d40sithui

2:40 pm on Aug 16, 2007 (gmt 0)

10+ Year Member



btw heres an example for reloading a page based on the number of records.

<?

<SELECT name='page' onchange=\"reload(this.form);\">\n";

if($valid_page!=1){
$page = 10;
}
for($i =5; $i <= $max_pages; $i+=5){
if($i == $page){
echo "<option selected value=$i>$i</option>\n";
}
else{
echo "<option value=$i>$i</option>\n";
}

}//ends for

echo"</SELECT>\n";

?>

jonk

2:48 pm on Aug 16, 2007 (gmt 0)

10+ Year Member



<option value=something1 selected="selected">something1</option>

<option value=something2>something2</option>

<option value=something3>something3</option>

<option value=something4>something4</option>

<option value=something5>something5</option>

sets something1 to default if you like.

how does

<option selected value=something1>something1</option>

<option selected value=something2>something2</option>
..
..
<option selected value=something5>something5</option>

work? or am I missing the point?!

d40sithui

5:43 pm on Aug 16, 2007 (gmt 0)

10+ Year Member



the first part of your reply makes sense as thats what you should have. theres no point to the 2nd portion. how did you get that code?