Forums

How do I display the value on screen for a selection in a radio group array?

cre8tivemedia 02 Sep, 2018
I can't figure out how to display the value of a field from a selected radio group.
I've figured out how to pass the value from a dropdown and tried to use similar settings for a radio group to no avail...







I've set the javascript as follows -
function myFunction() {

var x = document.getElementById("checkboxes61").value;
document.getElementById("demo").innerHTML = x;

var y = document.getElementById("discount").value;
document.getElementById("demo2").innerHTML = y;

var z = Number(x) + Number(y);
document.getElementById("demo3").innerHTML = z;

var a = z * (.3*10) / 10;
document.getElementById("demo4").innerHTML = a;

var b = document.getElementById("radio123").value;
document.getElementById("demo5").innerHTML = b;

}

Html as follows -
 <body onload="myFunction()"> 


<div style="background-color:lightblue">
<h4>Checkboxes Value</h4>
<p id="demo"></p>
</div>
<p></p>

<div style="background-color:lightblue">
<h4>Dropdown Value</h4>
<p id="demo2"></p>
</div>
<p></p>

<div style="background-color:lightblue">
<h4>Add Checkbox and Dropdown fields</h4>
<p id="demo3"></p>
</div>
<p></p>

<div style="background-color:lightblue">
<h4>Add Checkbox and Dropdown fields then Multiply by .3</h4>
<p id="demo4"></p>
</div>
<p></p>

<div style="background-color:gray">
<h4>Value of Radio Group</h4>
<p id="demo5"></p>
</div>
<p></p>

</body>

If I set the id as "radio1230" or "radio1231" it returns the values but when I click on them to change nothing happens...

Same result with the checkboxes as well

Here is a frontend link - http://coupons.cuttingcoupons.net/index.php?option=com_chronoforms6&chronoform=calcs

Any help would be appreciated,
Matt

CFV6
Joomla 3.8.12
healyhatman 03 Sep, 2018
Answer
1 Likes
https://stackoverflow.com/questions/51105243/get-value-of-radio-checked-in-semantic-ui

You need to use
var x = jQuery("input[name='radio123']:checked").val();
cre8tivemedia 03 Sep, 2018
Thanks healyhatman!
Got it to work, I had the name as "radio9" which was different from the id of "radio123" which tripped me up for a little bit but the code worked perfectly once I realized.

Matt
This topic is locked and no more replies can be posted.