Solved

Adding the number of selected radio buttons within a form

Posted on 2008-10-19
6
648 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 3

Expert Comment

by:siranm
Comment Utility
sorry, i totally misread the context !
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
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
Comment Utility
Thanks Shuboarder works well !!!!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

11 Experts available now in Live!

Get 1:1 Help Now