Solved

Adding the number of selected radio buttons within a form

Posted on 2008-10-19
6
655 Views
Last Modified: 2013-12-18
Creating a small survey consisting of 13 questions in which there are answers A,B,C (Radio buttons)
How do you add the individually selected radio buttons to provide a total. of each. i.e how may A's, B's and C's. I have attached the lotus notes database to help explain.

Thanks.


Radio-Buttons-Total.bmp
0
Comment
Question by:ianmcalder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Expert Comment

by:siranm
ID: 22755189
The names of the radio buttons could be A1, A2, A3..., B1, B2, B3....

You would then iterate through the elements contained in some div (which could contain the table), and you check with what letter the name of the Radio starts

example1 taken from : http://www.javascriptkit.com/domref/elementproperties.shtml

example2 taken from : http://www.java2s.com/Code/JavaScriptReference/Javascript-Collections/childNodesExample.htm



example1:
//access some <ul> element
var mylist=document.getElementById("mylist")
for (i=0; i<mylist.childNodes.length; i++){
if (mylist.childNodes[i].nodeName=="LI")
//do something
}
 
example2:
 
<html>
<head>
<script language="JavaScript">
function function1() {
    var m = document.all.myBody.childNodes;
    alert(m.length) 
}
</script>
</head>
<body id="myBody">
<input id=myB 
       type="button" 
       value="How many child nodes have this body element?" 
       onclick="function1()">
</body>
</html>

Open in new window

0
 
LVL 3

Expert Comment

by:siranm
ID: 22755210
document.getElementById("elementID").childNodes // returns all child nodes

***document.getElementById("elementID").childNodes(param1) // returns an individual *** (you can access properties of the individual, like it's name)

document.all.elementID.childNodes // IE only
document.all.elementID.childNodes(param1) // IE only


param1   Required; zero-based index

taken from same page as example2
0
 
LVL 21

Accepted Solution

by:
shuboarder earned 250 total points
ID: 22756435
Hi,

assuming your question fields are called q1 - q13

Total As =

total := @Trim(q1:q2:q3:q4:q5:q6:q7:q8:q9:q10:q11:q12:q13);
result := @Trim(@Replace( total ; "B":"C" ; "":""));
@If(result="";0;@Count(result))

Total Bs =

total := @Trim(q1:q2:q3:q4:q5:q6:q7:q8:q9:q10:q11:q12:q13);
result := @Trim(@Replace( total ; "A":"C" ; "":""));
@If(result="";0;@Count(result))

Total Cs =

total := @Trim(q1:q2:q3:q4:q5:q6:q7:q8:q9:q10:q11:q12:q13);
result := @Trim(@Replace( total ; "A":"B" ; "":""));
@If(result="";0;@Count(result))
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:siranm
ID: 22756542
sorry, i totally misread the context !
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 22757198
May other ways (just for fun, not points!):

total := @Trim(q1:q2:q3:q4:q5:q6:q7:q8:q9:q10:q11:q12:q13);
totA:= @Sum(@TextToNumber(@Replace("A":"B":"C"; "1":"0":"0")));
totB:= @Sum(@TextToNumber(@Replace("A":"B":"C"; "0":"1":"0")));
totC:= @Sum(@TextToNumber(@Replace("A":"B":"C"; "0":"0":"1")))

Or:

total := @Trim(q1:q2:q3:q4:q5:q6:q7:q8:q9:q10:q11:q12:q13);
totaln:= @Sum(@TextToNumber(@Replace("A":"B":"C"; "1":"1000":"1000000")));
totA:= @Modulo(totaln; 1000);
totB:= @Modulo(@Integer(totaln/1000); 1000);
totB:= @Integer(totaln/1000000)
0
 

Author Closing Comment

by:ianmcalder
ID: 31507710
Thanks Shuboarder works well !!!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question