javascript - Validation -- Only when checkbox is checked and Radio button checked -



javascript - Validation -- Only when checkbox is checked and Radio button checked -

the demo

should pretty explanatory.

there rows radio buttons , check box @ end.

help 1. when check box checked, values of checked radio button , along value of textarea , dropdown (if missing radio button clicked) populated in text area @ bottom?

help 2. right when radio button clicked, checked radio buttons value showing. going wrong ?

to help understand, text area, info separated ~ , | gets passed on next stage when save button clicked. when page loads radio buttons pre-checked depending on previous page nil needs populated in bottom text area.

we utilize jquery 1.6.4

function updatesummary($this){ $this.closest('[id]').find('.r-title, .m-notes-wrapper, .up-arrow, .down-arrow').hide(); var totalrd = $('table').find('input:radio:checked').length; // array of clicked items var clicked = []; // set number of selected items $("#totalrd .rd-count").html(totalrd); // show title , notes next radio button $this.siblings('.r-title, .m-notes-wrapper, .up-arrow, .down-arrow').show(); // find checked radio buttons has been clicked $('table').find("input[type=radio]:checked:enabled").each(function () { // find closest ancestor id // see if have text box, if utilize text var $text = $(this).parent().find('textarea.m-notes:visible'); var missingreason = $(this).parent().find('.reason').val(); var selectedid = $(this).closest('[id]').attr('id'); var value = selectedid + "~" + $(this).val(); if ($text.length) { value += "~" + missingreason +"~" + $text.val(); } clicked.push(value); }); //checked // display selected ids $("#inputhere").val(clicked.join('|')); } // radio selection changes selected options $("input:radio").click(function () { updatesummary($(this)); }); $('textarea.m-notes').bind('keyup', function () { updatesummary($(this).siblings(':radio')); }); $('select.reason').change (function () { updatesummary($(this).siblings(':radio')); }); $("input:checkbox").change(function(){ updatesummary($(this)); });

thanks help.

you add together status when updating textarea :

if($('table').find("input[type=checkbox][name='" + $(this).attr('name') + "']").is(':checked')) { var $text = $(this).parent().find('textarea.m-notes:visible'); var missingreason = $(this).parent().find('.reason').val(); var selectedid = $(this).closest('[id]').attr('id'); var value = selectedid + "~" + $(this).val(); if ($text.length) { value += "~" + missingreason +"~" + $text.val(); } clicked.push(value); }

javascript jquery

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

html - Submenu setup with jquery and effect 'fold' -

ruby on rails - Devise Logout Error in RoR -