Conditional form fields question

Discussion in 'PHP' started by BobC, Sep 23, 2010.

  1. #1
    Hi,

    I'm having a very steep learning curve right now but have got my head around hidden variables to make a 2 page form. However I'm stuck on the next bit.

    I can pass variables from page 1 to page 2 ok, but I need one of the values to trigger particular form fields.

    On page 1 I have a question - if the answer is 'yes' I just go to the basic form on page 2. If the answer is 'no' I need to add a couple of extra fields to the form on page 2.

    I think I need some sort of conditional statements here but am not sure right now how to implement this.

    Is there an easy solution to this?

    Thanks
     
    BobC, Sep 23, 2010 IP
  2. Internet Monk

    Internet Monk Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php if (!empty($_POST['trigger']) && $_POST['trigger'] == "no") { ?>
    
    <input type="text" name="trigger-explanation">
    
    <?php } ?>
    PHP:
    I think there's no need for an explanation, right ?
     
    Internet Monk, Sep 23, 2010 IP
  3. BobC

    BobC Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the speedy reply! I'm not sure i can get my head totally around that right now but I'll have another look in the morning when I'm fresh :)

    cheers
     
    BobC, Sep 23, 2010 IP