Jump to content

total.noob() but trying to understand...


phatgreenbuds

Recommended Posts

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.

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.