Search code examples
jquerywordpressradio-button

jQuery forcing radio buttons to check wrong button


Im using jQuery to put the value from a radio button and input it into a field. But the jQuery is forcing the last button to always be selected. The radio input in Question is the 5th one down called Please Specify

Check http://designfitz.com/product/thesis

This is the code

jQuery(function() {
  jQuery('input[name="input_88"]').click(function () {
    var themethod =jQuery(this).val();
    jQuery("#input_3_7").val(themethod);
  }).click();
});

I've deleted all other javascript on the page and disabled all plugins in wordpress and it still happens.

Any insights?


Solution

  • input_88 will be selected on page load as you are triggering click event on it

    remove that .click() in the end -

    jQuery(function() {
      jQuery('input[name="input_88"]').click(function () {
        var themethod =jQuery(this).val();
        jQuery("#input_3_7").val(themethod);
      });
    });