+ Reply to Thread
Results 1 to 3 of 3

Thread: Trying to create a multiform that determines next_form based on radio button choice?

  1. #1
    Join Date
    Jun 2012
    Posts
    5

    Default Trying to create a multiform that determines next_form based on radio button choice?

    Don't know if this is possible. I'm new to PHP, so I'm just trying random stuff here. I turned my index.html into an index.php so I would have access to if/else statements. Basically I've got this right now:

    Code:
    ....
    
    
    <dl>
    <dt>Are you a new or existing customer?*</dt>
        <dd>
            <input type="radio" name="Customer" id="customer-new" value="false" /><label for="customer-new">New</label>
            <input type="radio" name="Customer" id="customer-old" value="true" /><label for="customer-old">Existing</label>
        </dd>
    </dl>
                            
    <input type="hidden" name="next_form" value="
        <?php
            $selected_radio = $_POST['Customer'];
                                
            if(!($selected_radio))
            {
                echo('new.html');
            } 
            else
            {
                echo('existing.html');
            }
        ?>"
    />
    
    <input type="submit" name="submit" value="Next" />
    Right now, no matter if "New" (false) or "Existing" (true) is selected it sends me to "new.html", but the FormMail email I get does correctly say true or false based on my choice.

    I've got a feeling it's not working because of PHP being server side, so it doesn't evaluate the conditional until after it's already on it's way to the next page? Is this something I would need to the FormMail Computation Module for?

  2. #2
    Join Date
    Jun 2012
    Posts
    5

    Default Re: Trying to create a multiform that determines next_form based on radio button choi

    Aright, I figured it out with JQuery instead of PHP.

    In case anyone was wondering...

    Code:
    <script>
        $(":radio").click(function () {
            if($('#customer_new').is(':checked'))
            {
                $("#next_form").val("new.html");
            } else {
                $("#next_form").val("existing.html");
            }
        });
    </script>
    Still interested to know if it's possible to do with PHP though, in case users have JS turned off.

  3. #3
    Join Date
    Mar 2004
    Posts
    2,224

    Default Re: Trying to create a multiform that determines next_form based on radio button choi

    yep, PHP happens server side so it can't affect what's happening in the browser until u submit the form

    u need javascript for that

    tectites computation module works server side too, i think the main advantage is it lets u do calculations on the submitted fields without resorting to extra php code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Radio Button Options
    By OldSnipe in forum Community Support
    Replies: 1
    Last Post: 30-Jan-2011, 04:49 PM
  2. Radio button values
    By Dubbarob in forum Community Support
    Replies: 2
    Last Post: 27-Oct-2008, 05:56 PM
  3. Use template based on radio button selected
    By Jamesiv1 in forum Community Support
    Replies: 1
    Last Post: 17-Mar-2008, 12:29 PM
  4. Replies: 1
    Last Post: 24-Feb-2008, 06:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts