Log in

View Full Version : Help with submit form



beo77388
03-05-2010, 02:03 AM
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/

?>

bluewalrus
03-05-2010, 06:07 AM
This sounds like it should be done through java-script or a client side language to me.

beo77388
03-06-2010, 02:07 PM
Thanks bluewalrus. Let me try that.