Hey guys
New to PHP and programming in general. I am writing my first PHP form to spit out some "instant" answers based on user input. Basically, i want the form choices to change automatically(without page reload) depending on the choices made before it . I do not know AJAX or JS but if anyone is willing to help i would greatly appreciate it! Thanks in advance.
Basically, i will have 2 forms and one will show if $outside isset and the other will show if $inside isset but i do not want the user to have to reload the page. Does this makes sense? Thanks a million for your help.
<?php if($_POST['in_or_out'] == "inside" ) { $inside = $_POST['in_or_out']; } elseif($_POST['in_or_out'] == "outside" ) {$outside = $_POST['in_or_out']; }?>
</head>
<body>
<h4> Please answer the following questions to receive a hardware recommendation or Fill out the contact us form for more complex questions</h4>
<?php if(!isset($_POST["form"])) { ?>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']) ?>" method="post" name="form">
<p>Indoor or Outdoor : <select name='in_or_out'><option value=''>Select one</option><option name="inside" <?php if(isset($inside)){echo "selected"; }?> value="inside">Inside</option><option name="outside" <?php if(isset($outside)) {echo "selected" ; } ?> value="outside">Outside</option>
</select>
</p>
<?php if(isset($outside)) { ?>
<select name="application" >
<option value="opt1">opt1</option>
<option value="opt2">opt2</option>
<option value="opt3">opt3</option>
</select>
<?php } elseif(isset($inside)) { ?>
<select name="application" >
<option value="opt1">opt1</option>
<option value="opt2">opt2</option>
</select>
<?php } ?>
<br />
<input type="submit" name="submit" value="Submit">
</form>
<?php } ?>
</body>
</html>