1

I am a begineer in website designing.I have a form in which I have few radio buttons/checkboxes. User has the option of selecting the radio/checkboxes. When user selects any of the radio/checkboxes,I need to send this information to server and fetch the required data from the server which is basically a sql.

Example: Radio buttons 1.male 2.female CheckBoxes Living in 1.India 2.United States 3.Australia

So depending upon the user data,I have to fetch data from server and show it to the user.

Any insight on how to achieve this?I am planning to use AJAX/JQuery to achieve this.

If there is a better way to do this,please let me know.Thanks in advance.

Ravikanth
  • 83
  • 8
  • There is answer at StackOverFlow: http://stackoverflow.com/questions/1200266/submit-a-form-using-jquery – romik Oct 19 '13 at 20:05

1 Answers1

0

You are on the right track I think. Assuming <input type='radio' id='radiobox'/> for a radiobox using jQuery you'll do something like

$('#radiobox').click(function () {
  var val = $(this).val();
  $.get('/url',
      val)
    .done(function (data) {
      // Dynamically add more fields
      // using data from server
    });
});
beautifulcoder
  • 10,832
  • 3
  • 19
  • 29
  • Thanks coder.But this would send only the data received from the particular event correct(in the above example a radio box click event)?What if the user has already selected 2 checkboxes previously and then he is selecting a new checkbox?So,now i should be presenting the user which includes all the 3 checkboxes?Pls bear with my ignorance. – Ravikanth Oct 19 '13 at 20:08
  • You can send as much data as you want to the server in the form of a JSON. Say `$.get('/url', {'opt1':$('#rad1').val(), 'opt2':$('#rad2').val(), 'opt3':$(this).val()})`. Hope that helps. – beautifulcoder Oct 19 '13 at 20:14