Forums

Show a result according to 2 fields combination values

deltafidesign 21 Oct, 2014
Hi,

I would like to create a form where user select values in 2 fields (first field is dropdown and second field radio button), then according to the combination of those 2 values I would like to output an html message.

How can I do that?

Thanks in advice.
GreyHead 21 Oct, 2014
Hi deltafidesign,

You can do that with PHP in a Custom Code element in the form On Submit action.

Bob
deltafidesign 21 Oct, 2014
Thanks GreyHead for your reply.

Could you please suggest me the PHP code I should use? I'm not gode in PHP.... sorry. :-(
GreyHead 30 Oct, 2014
Hi deltafidesign,

Here's an example assuming that the drop-down has values aaa and bbb and the radio button xxx and yyy
<?php
$message = '';
if ( $form->data['drop_down'] == 'aaa' && $form->data['radio_button'] == 'xxx' ) {
  $form->data['message'] = 'this message';
} elseif ( $form->data['drop_down'] == 'aaa' && $form->data['radio_button'] == 'yyy' ) {
  $form->data['message'] = 'this message';
}
} elseif ( $form->data['drop_down'] == 'bbb' && $form->data['radio_button'] == 'xxx' ) {
  $form->data['message'] = 'some other message';
}
} elseif ( $form->data['drop_down'] == 'bbb' && $form->data['radio_button'] == 'yyy' ) {
  $form->data['message'] = 'this last message';
}
?> 

Bob
This topic is locked and no more replies can be posted.