Javascript to update text box when radio button are automatically checked -
i creating set of radio buttons, when checked, update text box of options checked. however, if select 1 of 4 options remaining part of text box populate 'undefined' each remaining button isn't clicked, in case three.
to try , avoid getting 'undefined' , show options in text field @ once created script automatically check radio buttons after time has passed. but, doesn't update text field if had clicked on button. ideas?
here's code checks them, , code puts them in text field..
var allelems = document.getelementsbytagname('input'); settimeout(function() { (i = 0; < allelems.length; i++) { if (allelems[i].type == 'radio') { allelems[i].checked = true; } } }, 5000); $('input[name="o1"]').on('change', function() { $('input[id="text-yui_3_17_2_1_1502294158679_90364-field"]').val($('input[name="o1"]:checked').val()+$('input[name="o2"]:checked').val()+$('input[name="o3"]:checked').val()+$('input[name="o4"]:checked').val()); });
Comments
Post a Comment