Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Adding the number of selected radio buttons within a form

Posted on 2008-10-19
6
Medium Priority
?
671 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
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 1000 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

Technology Partners: 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

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

971 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