mercredi 12 octobre 2016

PHP IF Statement within HTML FORM

Can you put a PHP IF() statement within an HTML form?

I am looking to make an adaptive form depending on the previous selected options.

Snippet:

<label for="#">Pick a #:</label><br/>
<select id="#" name="#" form="#" value="<?php echo $#;?>" required>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
        </select><br/>
        <br/>
 <label for="Reason">Reason:</label><br/>
 <select id="Reason" name="Reason" form="Reason" value="<?php echo $Reason;?>" required>
        <?php

        if ($# === "1"){
        ?>
            <option value="R1">Unique</option>
            <option value="R2">Lonely</option>
            <option value="R3">Supreme Leader</option>
            <option value="R4">Excess Space</option>
        <?php
        }

The selection box does appear, but with no drop-downs, regardless what is selected in the "#" section.

Not opposed to using Javascript, just wondering if this is possible.

Aucun commentaire:

Enregistrer un commentaire