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
https://forums.phpfreaks.com/topic/158041-totalnoob-but-trying-to-understand/
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.