magic2goodil Posted January 12, 2007 Share Posted January 12, 2007 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 https://forums.phpfreaks.com/topic/33840-select-box-question/ Share on other sites More sharing options...
fenway Posted January 15, 2007 Share Posted January 15, 2007 Well, you can't survive a reload like that, unless you change the URL. Link to comment https://forums.phpfreaks.com/topic/33840-select-box-question/#findComment-161429 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.