In a database I have a table 'courses' and each course has number of sections(1,2,3,...) all stored in table 'sections'.
I want to make a form where the user selects a course from the available courses, then displays another selection input with the course's sections to choose from.
Here's what I've done, it worked but when I click 'next' after selecting the course and the section selection shows up, the name of the course selected will not show up. Does anyone know an easier way to do this using PHP or javascript? Can you show me how please.
<form id="form2" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post" onsubmit="return checkData();">
<label for="ccode">Select Course:</label>
<select name='ccode' required>
<option selected="true" disabled="disabled" value="">Select</option>";
<?php
foreach ($courses as $c)
{
echo "<option >".$c."</option>";
} ?>
</select><br>
<?php
extract($_POST);
if(isset($_POST['next']))
{
if(isset($ccode))
{
echo"<label for='upsection'>Select section:</label>
<select name='upsection' id='upsection' required>
<option selected='true' disabled='disabled' value=''>Select</option>";
foreach ($sec as $s)
{
echo "<option >".$s."</option>";
}
echo "</select><br>";
}
else
{
echo "<script>alert('Please select a course!');</script>";
}
if(isset($_POST['upsection']))
{
header('location: updatesection.php');
}
}?>
<button name='next' id='next' >Next</button><br>
</form>
I'm not good at explaining things but I hope you understand, and can help me with this:)
Via Active questions tagged javascript - Stack Overflow https://ift.tt/XzfpWjk
Comments
Post a Comment