Results 1 to 3 of 3

Thread: Help with submit form

  1. #1
    Join Date
    Mar 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with submit form

    Hello,

    I wonder if you can help with this simple php form below (no db involved) and give the most elegant answer to this challenge.
    I want to add a function to the submit that gets the total for the checked "yes" buttons only. Then multiply by 100 and divide by number of questions (to get %). If % is below 55% then load page http://example.com/pagex; if above 55% then load page http://example.com/pagey.

    Thank you for your reply.

    Code below (of the questions):
    <?php

    function quiz_form ($form_state) {
    $form = array();

    $form ['q1'] =array (
    '#type' => 'radios',
    '#title' => t('1. Do you like to drink coffee?'),
    '#options' => array('first' => t('Yes'),'second' => t('No')),
    '#required' => TRUE,
    );

    $form ['q2'] =array (
    '#type' => 'radios',
    '#title' => t('2. Do you drink coffee every morning?'),
    '#options' => array('first' => t('Yes'),'second' => t('No')),
    '#required' => TRUE,
    ); n/

    $form ['q3'] =array (
    '#type' => 'radios',
    '#title' => t('3. Do you drink coffee more than once a day?'),
    '#options' => array('first' => t('Yes'),'second' => t('No')),
    '#required' => TRUE,
    ); n/

    ?>

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    This sounds like it should be done through java-script or a client side language to me.
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    Mar 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks bluewalrus. Let me try that.

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
  •