0

Is there a way for users to see the choices he/she already made on the form on real-time? For example a user clicked a checkbox or radio button and on the bottom part of the form it shows all the choices he/she made without saving it yet. Basically its like a summary of all the choices the user made on the bottom part of the form without actually saving the form.

I've been trying this for a while now, any help or suggestions would be really appreciated.

Thank you

1 Answer 1

0

Use Jquery. For example, at bottom of your form you can append new container:

$('.your_form').append('<div class="summary"></div>');

and then by adding to your input elements click/change listeners add their values to your new container:

$( "#name input" ).change(function() { $('.summary').html($( this ).val()); });

4
  • Paul Nike thanks for your answer, I've tried it and it worked! Thanks man. I have another question though bcoz I'm actually using entity reference for the choices on the radio button to filter certain types of nodes. When I click on a radio button on the form only the NID of the choice appears on the <div class="summary"></div> but what I want is the title of the node not the NID, do you know how to call the title on jqeury? Apr 1, 2015 at 6:33
  • You need to write small module for form_alter, something like this function MYMODULE_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'your_form_id') { $options = $form['your_radios']['#options']; $new_options = array(); foreach($options as $key->$value){ $node = node_load($key); $new_options[$node->title] = $value; } $form['your_radios']['#options'] = $new_options; } } With debugger this task will be done easier. Another way is to write ajax function in your menu callback, but I think first way is much easier.
    – Paul Nike
    Apr 1, 2015 at 8:22
  • sorry, in foreach($options as $key->$value) typo. Correct version is foreach($options as $key=>$value)
    – Paul Nike
    Apr 1, 2015 at 11:27
  • Sorry for the late reply. I haven't had time to try it yet but I will later. :) Wish there was an easier way though than creating a custom module. Apr 6, 2015 at 2:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.