Jump to content

Js To Clear Conditional Child Input Fields


Recommended Posts

i have a field on a submission data page which if checked will display other other fields to be checked which have been hidden by a rule, but if I un-check the parent field the children fields disappear but remain checked. Can I use JS to clear the children cells if the parent is un-checked?

many thanks

 

Link to comment
Share on other sites

Hello costar,

 

You can use following code in the footer field: 

<SCRIPT type="text/javascript">

function f_a(v_id){ return document.getElementById(v_id); }
function f_b(v_id){ return f_a('InsertRecordcheckbox' + v_id);}
function f_findParentTR(v_node){
 var v_parentNode = v_node;
 if(!v_node) return null;
 while(v_parentNode && String(v_parentNode.nodeName).toUpperCase() != 'TR')
  v_parentNode = v_parentNode.parentNode;

 return v_parentNode;
}
function CheckboxesCheck() {
 if (f_b("1").checked){
  f_b("2").checked=true;
  f_b("3").checked=true;
 } else {
    if(!f_b("2").checked){
    f_findParentTR(f_b("2")).style.display='none';
    }
    if(!f_b("3").checked){
    f_findParentTR(f_b("3")).style.display='none';
    }
 }
}
f_b("1").onchange=CheckboxesCheck;
</script>

Note: The code works for three fields with 'Yes/No' DataTypes. 

 

Hope it helps.

 

IREN

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...