lifelineamerica
Programmer
I'm trying to display values selected via radio button. It works fine as:
function GetSelectedItem() {
var thefrm = document.forms['showtimes'].elements;
var theans = thefrm['time_id[]'];
for(i=0;i<theans.length;i++) {
theel = theans;
tnum=theel.value
if(theel.checked == true){
document.getElementById('outputText').innerHTML = "$" + (tnum);
}
}
}
I want to output the value in nice decimal format so I changed the code to:
function GetSelectedItem() {
var thefrm = document.forms['showtimes'].elements;
var theans = thefrm['time_id[]'];
for(i=0;i<theans.length;i++) {
theel = theans;
tnum=theel.value
result=tnum.toFixed(2);
if(theel.checked == true){
document.getElementById('outputText').innerHTML = "$" + (result);
}
}
}
I get the following error:
TypeError: Result of expression 'tnum.toFixed' [undefined] is not a function.
Apparenttly it's not letting me run the toFixed() function on a variable?
function GetSelectedItem() {
var thefrm = document.forms['showtimes'].elements;
var theans = thefrm['time_id[]'];
for(i=0;i<theans.length;i++) {
theel = theans;
tnum=theel.value
if(theel.checked == true){
document.getElementById('outputText').innerHTML = "$" + (tnum);
}
}
}
I want to output the value in nice decimal format so I changed the code to:
function GetSelectedItem() {
var thefrm = document.forms['showtimes'].elements;
var theans = thefrm['time_id[]'];
for(i=0;i<theans.length;i++) {
theel = theans;
tnum=theel.value
result=tnum.toFixed(2);
if(theel.checked == true){
document.getElementById('outputText').innerHTML = "$" + (result);
}
}
}
I get the following error:
TypeError: Result of expression 'tnum.toFixed' [undefined] is not a function.
Apparenttly it's not letting me run the toFixed() function on a variable?