Solved

Adding the number of selected radio buttons within a form

Posted on 2008-10-19
6
649 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 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lotus Domino - LKMgr Long Held Lock Dump 10 2,684
Mobile Iron iphone stop receiving new mails 6 1,223
Only send email if contains "abcd" 3 144
how to install domino server on suse linux 18 78
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…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
A short film showing how OnPage and Connectwise integration works.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

929 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now