Solved

Adding the number of selected radio buttons within a form

Posted on 2008-10-19
6
658 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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
Lotus Notes 8.5 1 168
Using @Prompt in a Queryclose Event 14 91
Save conflict messages on existing documents 15 109
Lotus Notes - Create multiple records from a dialog list 31 43
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

751 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