I have a page with 2 select option dropdown lists
and I can only use one of them each time I have to submit the selected option but if I use two and click on submit i get an error Only use one list and thats how it should work.
for example:
I have 2 drop lists like this one
if i choose both like the pic above and click on submit I get an error and the selected options are shown as the deffult option and thats what I want, but when I click on the reset button it need to reset them to the default value but nothing happens.
like this
The Options for the dropdown list is from two different arrays.
$test1
and $test2
are two different arrays
<form name="rechner" method = "POST">
<select name="one">
<option value="" selected hidden>Choose One</option>
<?php foreach ($test1 as $one => $value) { ?>
<option value="<?= $value ?>"
<?php if ($_POST['one'] == $value) {
echo 'selected="selected"';}?> ><?= $value ?>
</option><?php
}
?>
</select>
<select name="two">
<option value="" selected hidden>Choose one</option>
<?php foreach ($test2 as $two => $value) { ?>
<option value="<?= $value ?>"
<?php if ($_POST['two'] == $value) {
echo 'selected="selected"';}?> ><?= $value ?>
</option><?php
}
?>
</select>
<input type="submit" name="calc" value="Submit" />
<input type="reset" name="reset" value="Reset">
</form>
if ($_POST['calc'] == "Berechnen") {
/// do something
}