Jump to content

Select box question.


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 :P.
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.
[url=http://www.collegebookx.com/register.php]
http://www.collegebookx.com/register.php [/url]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.