phatgreenbuds Posted May 14, 2009 Share Posted May 14, 2009 So I am just starting down this path of javascript, seeing where I can enhance a php/mysql page with it. One thing I see right off is the ability to have pages appear to update dynamically without the need to use a submit button. So my plan is to try and create a branching form that depending on what options are selected in one section a resultant set of options will appear accordingly. I have been playing with this little bit of code that I found and have a few questions... <form action="./tester.php" method="GET"> <div align="center""> <select name="state" onchange="this.form.submit();"> <option>Choose One To Submit This Form</option> <option value="CA">CA</option> <option value="TX">TX</option> </select> </div> </form> <?php $test = $_GET['state']; //echo $test; if ($test == "CA") { echo "Ughhh another Liberal"; } else { if ($test == "TX") { echo "You Selected Texas...You ROCK!"; } } ?> This works so far and I admit I do not fully understand it yet but the fog is lifting. I'm curious how would I prevent the dropdown from resetting and instead change it to reflect the selected option? And as I start to branch this form further out for more options what would be the best way to preserve the previous selections. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 14, 2009 Share Posted May 14, 2009 Well, PHP can get the value of state that is passed. Use that to determine which option is selected. Looks more like a PHP or even a HTML problem to me. Not JavaScript-related. Quote Link to comment Share on other sites More sharing options...
phatgreenbuds Posted May 17, 2009 Author Share Posted May 17, 2009 I think I follow what your saying...just not sure how I would make it work. I will try posting this over in the PHP group. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.