Jump to content
  • 0

Update Checkbox When Virtual Radio Button Is Checked


eetimm

Question

I have a subscription form that is using a virtual radio button field (field: Virutal7) to force subscribers into choosing one of two versions. If the user clicks on the second option (Community Bank Version) I would like to update a hidden checkbox field (field: CBVer) with a check to track the version in our database. I am using the radio button so I can make the choice of a version a required field.

 

I wrote the following JS to attempt to switch the checkbox when the user selects the second option, but to no avail. If anyone could take a look at this I would greatly appreciate it.

 


 

 

 

<SCRIPT LANGUAGE="JavaScript">

 

function addcbver()

{

    if (document.getElementById('cbParamVirtual71').checked==true)

{

document.getElementById('InsertRecordCBVer').checked = true;

}

}

document.getElementByID('cbParamVirtual7').onchange=addcbver;

 

</SCRIPT>

 

 

Regards,

 

ET

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hello eetimm!

 

You were right, the issue was with virtual radio buttons.However, I have figured it out. I took IDs from your wed page, and I hope the following script works out  : 

 <script type="text/javascript">

  function start(){
   var form = document.getElementById('caspioform');
   if(!form) return;
   var radios = form['cbParamVirtual7'];

   for(var i = 0; i < radios.length; i++)
    radios[i].onchange = myFunc

  }
  function myFunc(evt){
   evt = evt || window.event;

   var node = evt.target || evt.srcElement

   document.getElementById('InsertRecordCBVer').checked = (node.value == '1');

  }
  start();

 </script>

I hope this helps.

 

Aurora

Link to comment
Share on other sites

  • 0

Hello eetimm!

 

Please try to correct the following lines of the script :

 

if (document.getElementById('cbParamVirtual71').checked==true)  

    

document.getElementById('cbParamVirtual7').onchange=addcbver

 

 

 

So the whole script will be as follows : 

<SCRIPT LANGUAGE="JavaScript">
 
function addcbver()
{
    if (document.getElementById('cbParamVirtual7').checked)
  {
document.getElementById('InsertRecordCBVer').checked = true;
  }
}
document.getElementById('cbParamVirtual7').onchange=addcbver;
 
</SCRIPT>
 

I hope this helps

 

Regards, 

 

Aurora :)

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
Answer this question...

×   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...
×
×
  • Create New...