Winunited Bonuses - Debt Consolidation - Bad Credit Personal Loans - Debt Consolidation - Wordpress Themes

PDA

View Full Version : Need help with using PHP to dynamically retain a selected value from a HUGE list.


Sapphiro
Apr 25th 2009, 11:26 pm
Hi people, really need help here.

Here's the situation:

I've got a registration page with a dropdown list of more than 300 records, and there are also other input fields as well, and the user will be returned back to the registration page if there are any missing input field (which means it wont pass the validation).

What I want is to have all of the already entered values to be retained on the registration page so that the user wont have to spend too much more time filling them up again. I have no problem with this with textboxes, but as for the dropdown menu, there's a huge problem.

Basically this is the best code that I think I could use so far:
<option VALUE="A"<?php if($_SESSION['Variable'] =="A"){ echo "A";} ?>>A</option>

but as you can see, there are more than 300 records, I don't wish to manually enter the variable inside, it'd be the best if there's any algorithm which works kinda like this (so I can just use them for any option:
<option value="bla" <?php checkifselected(this.option.value) ?>bla bla</option>

If anyone knows of a similar code, would you mind sharing with me? :o

creativeGenius
Apr 25th 2009, 11:50 pm
does your record come from a database?

Sapphiro
Apr 26th 2009, 1:10 am
hmm not for this, but I'm using session to return it from the validator page

Sapphiro
Apr 26th 2009, 10:45 pm
Hi all, I solved this problem myself, so I don't need anymore help already. :)

ghprod
Apr 27th 2009, 12:42 am
Hi all, I solved this problem myself, so I don't need anymore help already. :)
glad to hear that :)

regards