473,246 Members | 1,511 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

radiobutton values in JS?

hi... i cant seem to get value of set of radio buttons thru javscripting.. i hv set values to the radiobuttons but cannot retrieve them or calculate them in JS although it looks simple. do i need to convert the values to numeric in JS.. pls help me I am stuck..i hv pasted the code below:


********************************

[HTML]<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Do you have a rich mindset</title>

<script type="text/javascript">
function display(frm)
{
var val=0
var message =" Your final score is :\n\n "
for(var i=0;i<=r1[i].length;i++)
if (frm.r1[i].checked
{
val=val+frm.r1[i].value
}
for(var i=0;i<=r2[i].length;i++)
if (frm.r2[i].checked
{
val=val+frm.r2[i].value
}
for(var i=0;i<=r3[i].length;i++)
if (frm.r3[i].checked
{
val=val+frm.r3[i].value
}
for(var i=0;i<=r4[i].length;i++)
if (frm.r4[i].checked
{
val=val+frm.r4[i].value
}
for(var i=0;i<=r5[i].length;i++)
if (frm.r5[i].checked
{
val=val+frm.r5[i].value
}
message= message + val
alert(message)

</script>


</head>

<body>
<form name=Form1>
</form>
<p>&nbsp;</p>
<p><font color="#003399"><b><span style="FONT-SIZE: 14px; LINE-HEIGHT: 18px">
<font face="Verdana" color="#ff0000" size="4">Do you have a rich mindset?</font></span></b></p>
<ul>
<li><b><font face="Verdana" color="#3333ff" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">A customer comes just before
closing time.</span></font></b></li>
</ul>
<b><font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
<p style="COLOR: #000000; LINE-HEIGHT: 0px"><br>
&nbsp;</p>
</span></font></b>
<div style="FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 0px; FONT-FAMILY: Verdana">
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r1" VALUE=2> Do you attend to him willingly?</div>
</span></font>
<div style="FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 0px; FONT-FAMILY: Verdana">
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r1" VALUE=1></span><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">D</span><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">o
you attend to him grudgingly?</div>
</span></font>
<div style="FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 0px; FONT-FAMILY: Verdana">
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r1" VALUE=0></span><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">Do you ask him to come
the next day?<br>
&nbsp;</div>

</span></font><font size="2"><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
<ul>
<!-- CHECKING RADIO BUTTONS !-->
<li></span></font>&nbsp;<font color="#3333ff"><b><font face="Verdana" size="2"><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">A
business meeting coincides with your child’s birthday party.</span></font></b></font><b><font face="Verdana" color="#000000" size="2"><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px"></li>
</ul>
</span></font></b>
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r2" VALUE=1> Do you finish the meeting and
join the party late?</span></font><div style="FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 0px; FONT-FAMILY: Verdana">
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r2" VALUE=2>Do you
apologize to your
child and have another party?</span></font>

</div>
<div style="FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 0px; FONT-FAMILY: Verdana">
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r2" VALUE=0>Do you cancel the business
meeting?</span></font><font size="2"><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px"><ul>
<!-- CHECKING RADIO BUTTONS !-->
<li></span></font>&nbsp;<font color="#3333ff"><b><font face="Verdana" size="2"><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">A
customer keeps you waiting in his office.</span></font></b></font></li>
</ul>
<p>
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r3" VALUE=0>
</span>
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
Do you get frustrated and
angry?</span></font>
<div style="FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 0px; FONT-FAMILY: Verdana">
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r3" VALUE=1></span><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">Do you read a magazine
calmly?</span></font>&nbsp;

</div>
<div style="FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 0px; FONT-FAMILY: Verdana">
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r3" VALUE=2></span><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">Do you make calls related to
office work?</span></font></div>

</div>

<ul>
<li>
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;</span></font>
<font color="#3333ff"><b><font face="Verdana" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">You have only two out of four
skills required for your job.</span></font></b></font></li>
</ul>
<p>
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r4" VALUE=2> Do you put in efforts to
learn the other skills?</span></font>
<div style="FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 0px; FONT-FAMILY: Verdana">
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r4" VALUE=1></span><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">Do
you somehow manage?</span></font> &nbsp;

</div>
<div style="FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 0px; FONT-FAMILY: Verdana">
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r4" VALUE=0>D</span><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">o you look for another job?</span></font></div>

<ul>
<li>
<b><font face="Verdana" color="#3333ff" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">Your boss is away on a
business trip.</span></font><font face="Verdana" color="#000000" size="2"><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px"></li>
</span></font></b>
</li>
</ul>
<p>
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r5" VALUE=1>
</span>
</font></font><font face="Verdana" style="font-size: 12px">Do you work as usual?</font><font color="#003399"><div style="FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 0px; FONT-FAMILY: Verdana">
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r5" VALUE=2></span><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">Do you work more?</span></font></div>
<div style="FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 0px; FONT-FAMILY: Verdana">
<font face="Verdana" color="#000000" size="2">
<span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="r5" VALUE=0></span><span style="FONT-SIZE: 12px; LINE-HEIGHT: 16px">Do
you come late or leave early?</span></font><p>&nbsp;</p>

<p></p>
<p></p>


<p align="center">&nbsp;<input type="submit" align= "center" id= "submit" value="VIEW RESULT!" onClick="display(this.form)"></p>
</p>
</form>
</body>
</html>[/HTML]


***************************i cant seem to use document.write the radio button value either!! i need to add the values of selected radio buttons in each category and give a final score.Kindly help.......
renji
Apr 17 '07 #1
1 1819
acoder
16,027 Expert Mod 8TB
Welcome to TSDN.

You've closed your form tag straight after the opening tag.

Also, in your code,
Expand|Select|Wrap|Line Numbers
  1. if (frm.r1[i].checked
should have an ending brace:
Expand|Select|Wrap|Line Numbers
  1. if (frm.r1[i].checked)
If you have any more problems, post again.
Apr 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: VK | last post by:
Hi! What I'm missing in following code? Cannot get the values of radiobuttons. Starting only one class (GetVariant), it works. When I put two classes together, it doesn't. Regards, VK from...
11
by: William Gill | last post by:
I am placing radiobuttons in a 4 X 4 matrix (using loops) and keep references to them in a 2 dimensional list ( rBtns ). It works fine, and I can even make it so only one button per column can be...
3
by: sofie | last post by:
Hello all, I use the following javascript function in a html document to set the level of one of eight available radiobuttons. The line that's commented out works fine under IE, but I need to...
2
by: Sascha | last post by:
hello ng i have a group of 6 radiobuttons with different values. when i check a radiobutton, i have to calculate something with the value of the new ckecked radiobutton. can please someone...
0
by: dfetrow410 | last post by:
I am using a datalist. I need to retrieve only selected values. I tried to use the following code below with no luck. Not sure how to do the backend <tr> <td align="left" valign="top"><img...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.