Is it possible to show the last selected value from the drop down list box after form reload?

Recommended Answers

All 5 Replies

Thanks but actually my problem is that my form remembers the value after form RELOAD.But my drop down list box doesn't show the option that was selected to the user.
I have two three drop down list boxes where the selection of the first list box determines the values present in the second list and the values in the third list box are determine by the option selected in the second list box.
for this i have used

echo "<select name='country' onchange=\"reload(this.form)  \">
 <option value=''>Select country</option>";
while($noticia = mysql_fetch_array($quer)) { 
  if($noticia['countryID=']==$country){
  echo "<option value='$noticia[countryID]'>$noticia[countryName]  </option>"."<BR>";}
  }

so the values in the city list box are populated after the form reloads.
Problem is that after the form reloads the list box shows select country instead of the country selected by the user, although the form remembers the countryID of the country selected by the user.

hey did you get any solution for that .. ve been workin on thos for quite a long time.... if you ve got pls help me out !!!

Ahh, this is simple. Try this:

if($noticia['countryID=']==$country){
  echo "<option value='$noticia[countryID]' selected='selected'>$noticia[countryName]  </option>" . "<BR>";}
}

The key here is putting

selected='selected'

in the option tag for the country you want selected.

hey thanks a lot :)hey its kinda workin now......but if i m relading the page twice... the value selected in the first drop down list returns back to default value.... actually the page is totally reloaded thrice...i want the things to be maintained even after the first and the second reload ...wat do i do?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.