Jump to content

Js For For Adding Radio Button Value

Recommended Posts

I have a form that currently uses Dropdowns and want to change them to Radio buttons.


Not a biggie, but I'm not sure what I need to change on my script to make it work.

It seems that the radio button has 2 fields, so I think I have to somehow choose which is selected?

I'm a bit of a novice, so any help would be greatly appreciated.


Here is my current script:


function calculate()
var v_q1 = parseFloat(document.getElementById("InsertRecordSec1Q1").value);
var v_q2 = parseFloat(document.getElementById("InsertRecordSec1Q2").value);
var v_q3 = parseFloat(document.getElementById("InsertRecordSec1Q3").value);
var v_q4 = parseFloat(document.getElementById("InsertRecordSec1Q4").value);
var v_q5 = parseFloat(document.getElementById("InsertRecordSec1Q5").value);
var v_q6 = parseFloat(document.getElementById("InsertRecordSec1Q6").value);
   var v_Sec1total  = (v_q1+v_q2+v_q3+v_q4+v_q5+v_q6);
   document.getElementById("InsertRecordSec1TotalScore").value = Math.round(v_Sec1total);

Link to comment
Share on other sites

A Radio button includes multiple options. Each option has an associated id. The id is a name followed by a number:


  • X is the radio button option order and starts from 0. It increments based on the order of the option.


For example if your radio button has three options: Red, Blue, Green

  • Red is referenced by InsertRecordFIELDNAME0
  • Blue’s ID is InsertRecordFIELDNAME1
  • And the third option Red is referenced by InsertRecordFIELDNAME2
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.

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.

  • Create New...