Forum Moderators: coopster

Message Too Old, No Replies

Drop down boxes

         

chuckee

6:08 am on Aug 14, 2007 (gmt 0)

10+ Year Member



Hi,
On one of my pages I have a form with a country dropdown box, with every country in the world, so obviously it is quite big.

I was wondering if there is an easy to have the particular country that the user selected re-selected, if the user is returned back to the form based on an error on the rest of the form.
For example, if they have accidently submitted a blank field somewhere on the rest of the form and they are returned to the same form to correct the problem, I would like the country dropdown box to have what they previously selected, re-selected.

Is there some way to do this with the country dropdown box without about 250 'if' statements?

Cheers!

Habtom

6:39 am on Aug 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there some way to do this with the country dropdown box without about 250 'if' statements?

Do you get the values from the database? If you do, while looping them for display, you can compare values, and insert "selected='selected'" in the right option tag.

Without posting much of the code, post part of the code here.

[edited by: Habtom at 6:39 am (utc) on Aug. 14, 2007]

eelixduppy

9:02 am on Aug 14, 2007 (gmt 0)



Yep, that is how it is done. Here's a good example: [webmasterworld.com...]

chuckee

10:40 pm on Aug 14, 2007 (gmt 0)

10+ Year Member



Thanks very much for the help!