•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,568 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,589 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1679 | Replies: 3
![]() |
•
•
Join Date: Oct 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I have a form that has several radio groups that is used as a multiple choice test for users. Currently the form data is submitted to the educator via email. The poster receives and auto-reply email confirming the test was received. I would like to include the results of the test in the email.
How do I capture the value of each radio group and then add them altogether to get the final score. And then, how do I pass that value to a text box (or something) so that I can include it on the auto-reply email. I have found several articles/tutorial on this type of thing but I don't understand it enough to make it work.
If someone could help, I would be just too greatful.
How do I capture the value of each radio group and then add them altogether to get the final score. And then, how do I pass that value to a text box (or something) so that I can include it on the auto-reply email. I have found several articles/tutorial on this type of thing but I don't understand it enough to make it work.
If someone could help, I would be just too greatful.
You have to use a for loop to scan each group of radio buttons to find out which one has the attribute "checked" being true. Use the index of the loop as the value of the radio button found checked.
Then compare the values checked with the correct values. If the value is correct, add its worth to the score.
put the whole address of the text box on the left side of an assignment to put the score in the text box.
Then compare the values checked with the correct values. If the value is correct, add its worth to the score.
put the whole address of the text box on the left side of an assignment to put the score in the text box.
Daylight-saving time uses more gasoline
•
•
Join Date: Oct 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Thank you for your response. I have this code which produces the results that I am looking for but it has no error handling so if any questions are not completed, the score does not calculate. I have tried doing a loop function but I can't get it working for some reason.
<Script language = JavaScript>
function checkQonea(Q1a){
document.forms[0].Q1aScore.value=Q1a
}
function checkQoneb(Q1b){
document.forms[0].Q1bScore.value=Q1b
}
function calculate(){
A=eval(document.forms[0].Q1aScore.value)
B=eval(document.forms[0].Q1bScore.value)
C=(A+B)
document.forms[0].total.value = C+"%"
}
function message(){
result = C
if (result < 4) {
alert("I'm sorry. You did not score the minimum 80%. Please try again.")
}
else if(result >= 4) {
alert("Congratulations! You passed. Please submit your test now.")
}
}
</SCRIPT>
<Script language = JavaScript>
function checkQonea(Q1a){
document.forms[0].Q1aScore.value=Q1a
}
function checkQoneb(Q1b){
document.forms[0].Q1bScore.value=Q1b
}
function calculate(){
A=eval(document.forms[0].Q1aScore.value)
B=eval(document.forms[0].Q1bScore.value)
C=(A+B)
document.forms[0].total.value = C+"%"
}
function message(){
result = C
if (result < 4) {
alert("I'm sorry. You did not score the minimum 80%. Please try again.")
}
else if(result >= 4) {
alert("Congratulations! You passed. Please submit your test now.")
}
}
</SCRIPT>
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- selecting radio button values (Java)
- MySQL INSERT not working. Why? (MySQL)
- Trying to creating an array from a text file (C++)
- Jmail with radio buttons and menus (Site Layout and Usability)
- Python Sets? (Python)
- calling functions (ASP.NET)
- Insert radio button value into MS Access database (ASP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: List problem in firefox
- Next Thread: Ajax help



Linear Mode