Jump to content

Select box help.


magic2goodil

Recommended Posts

I have a code using php and javascript.

The code is set up for the user to select their state from a select box, and then the page refreshes with the 2 values in the url query, one being the 2 letter code of the state selected and the other being an ID that corresponds to the user selectedIndex.

I have a small javascript code at the top of my page that calls that ID adds it to my javascript line that reads document.register.State.options[ID].selected = true.  The exact code is actually the combination of a php echo, that then pulls the $_GET['ID'] from the url.  When I load the page, click on a state, it reloads the page and the variables load fine, and it pulls in the ID to the javascript line correctly as well.

But here is my question.  I was hoping that depending on what state was selected originally, that using the document.register.State.options[ID].selected = true would make it reflect on the page with that state still selected.  Instead of it doing that though, it just defaults back to the first option.  Am I going about this the wrong way?  Can anyone give me any insights as to what I can do different?

Here is the working code, although it needs some CSS editing Tongue.
What I am wanting is if you click on say California, when the page reloads with the $_GET vars in the url, I want California to still be selected.

http://www.collegebookx.com/register.php
Link to comment
https://forums.phpfreaks.com/topic/33846-select-box-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.