|
 |
asp_web_howto thread: count the user's input from the radio buttons
Message #1 by DEREK TRAN <derekhtran@y...> on Thu, 8 Nov 2001 23:21:29 -0800 (PST)
|
|
Hi All,
I have a question, how do you write the javascript to
display the total of yes and not dynamically, that is
when the user clicks on either radio button yes or no,
then the total will pop up in the text boxes (these
are not editable) without even clicking a submit
button. For example, if I clicks on the first radio
button for no, then it will say 1 on the right box, if
I choose another one for no, then the totalno will be
2, if I choose yes, then it will says 1 in the left
box (which is totalyes).
Another point is for example, the user chooses option
"yes", that is, the radio button yes is selected, then
the user wants to choose the other option, in this
case, "no". The total for the yes column should
decrease one, and the totla for the no column should
increase one.
Would someone help me please ASAP?
Thank you so much.
Dinh Nguyen
Below is the asp code/html code.
<title>Request Form</title>
<form name=Testing method="post" action="testing.asp">
<table width="650" border="1" cellpadding="1"
cellspacing="1" bgcolor="#FFFFFF"
bordercolor="#336699">
<tr>
<td height="34" colspan="4" valign="top"><b><font
face="Comic Sans MS" size="-1">Part
1 </font></b></td>
<td valign="top" colspan="2"><b><font face="Comic Sans
MS" size="-1">Yes</font></b></td>
<td valign="top"><b><font face="Comic Sans MS"
size="-1">No</font></b></td>
</tr>
<tr>
<td valign="top" colspan="4" height="34"><font
face="Comic Sans MS" size="-1">1.
Field 1</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch1_y1" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch1_n1" value="no">
</font></td>
</tr>
<tr>
<td valign="top" colspan="4" height="34"><font
face="Comic Sans MS" size="-1">2.
Field 2</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch2_y2" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch2_n2" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">3.
Field 3</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch3_y3" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch3_n3" value="yes">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">4.
Field4</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch4_y4" value="no">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch4_n4" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><b><font
face="Comic Sans MS" size="-1">Part
2 </font></b></td>
<td valign="top" colspan="2"><font face="Comic Sans
MS" size="-1"></font>
</td>
<td valign="top"><font face="Comic Sans MS"
size="-1"></font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">1
.Field 5</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch5_y5" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch5_n5" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">2.
Field 6</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch6_y6" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch6_n6" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">3.
Field 7</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch7_y7" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch7_n7" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">4.
Field 8</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch8_y8" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch8_n8" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">5.
Field 9</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch9_y9" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch9_n9" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">6.
Field 10</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch10_y10" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch10_n10" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1"><b>Total</b>
</font></td>
<td colspan="2" valign="top">
<input type="text" name="totalyes">
</td>
<td valign="top">
<input type="text" name="totalno">
</td>
</tr>
<tr>
<td valign="top" colspan="5" rowspan="2"><font
face="Comic Sans MS" size="-1">Note
any specific work area set-up concerns you have here:
<br>
<textarea name="concerns" cols="40"
rows="2"></textarea>
</font></td>
<td colspan="2" valign="top" height="51"> </td>
</tr>
<tr>
<td colspan="2" valign="top" height="37">
<input type="submit" name="Submit" value="Submit">
</td>
</tr>
</table>
</form>
__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com
Message #2 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Fri, 9 Nov 2001 11:00:07 -0000
|
|
you should give a group of radio buttons the same name so that they become
mutually exclusive.
e.g. instead of having 'ch1_y1' and 'ch1_n1', call both 'ch1'
then do something like this for the onclick function of each radio button
(pass in a string "y" or "n")
function increaseTotal(sYesNo){
switch(sYesNo){
case "y":
var oField = document.forms("Testing").totalyes;
break;
case "n":
var oField = document.forms("Testing").totalno;
break;
}
oField.value=parseInt(oField.value)+1;
}
although you will need to add a fair bit more code to allow for them
changing options etc
-----Original Message-----
From: DEREK TRAN [mailto:derekhtran@y...]
Sent: 09 November 2001 07:21
To: ASP Web HowTo
Subject: [asp_web_howto] count the user's input from the radio buttons
Hi All,
I have a question, how do you write the javascript to
display the total of yes and not dynamically, that is
when the user clicks on either radio button yes or no,
then the total will pop up in the text boxes (these
are not editable) without even clicking a submit
button. For example, if I clicks on the first radio
button for no, then it will say 1 on the right box, if
I choose another one for no, then the totalno will be
2, if I choose yes, then it will says 1 in the left
box (which is totalyes).
Another point is for example, the user chooses option
"yes", that is, the radio button yes is selected, then
the user wants to choose the other option, in this
case, "no". The total for the yes column should
decrease one, and the totla for the no column should
increase one.
Would someone help me please ASAP?
Thank you so much.
Dinh Nguyen
Below is the asp code/html code.
<title>Request Form</title>
<form name=Testing method="post" action="testing.asp">
<table width="650" border="1" cellpadding="1"
cellspacing="1" bgcolor="#FFFFFF"
bordercolor="#336699">
<tr>
<td height="34" colspan="4" valign="top"><b><font
face="Comic Sans MS" size="-1">Part
1 </font></b></td>
<td valign="top" colspan="2"><b><font face="Comic Sans
MS" size="-1">Yes</font></b></td>
<td valign="top"><b><font face="Comic Sans MS"
size="-1">No</font></b></td>
</tr>
<tr>
<td valign="top" colspan="4" height="34"><font
face="Comic Sans MS" size="-1">1.
Field 1</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch1_y1" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch1_n1" value="no">
</font></td>
</tr>
<tr>
<td valign="top" colspan="4" height="34"><font
face="Comic Sans MS" size="-1">2.
Field 2</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch2_y2" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch2_n2" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">3.
Field 3</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch3_y3" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch3_n3" value="yes">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">4.
Field4</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch4_y4" value="no">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch4_n4" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><b><font
face="Comic Sans MS" size="-1">Part
2 </font></b></td>
<td valign="top" colspan="2"><font face="Comic Sans
MS" size="-1"></font>
</td>
<td valign="top"><font face="Comic Sans MS"
size="-1"></font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">1
.Field 5</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch5_y5" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch5_n5" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">2.
Field 6</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch6_y6" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch6_n6" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">3.
Field 7</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch7_y7" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch7_n7" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">4.
Field 8</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch8_y8" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch8_n8" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">5.
Field 9</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch9_y9" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch9_n9" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1">6.
Field 10</font></td>
<td valign="top" colspan="2"> <font face="Comic Sans
MS" size="-1">
<input type="radio" name="ch10_y10" value="yes">
</font></td>
<td valign="top"> <font face="Comic Sans MS"
size="-1">
<input type="radio" name="ch10_n10" value="no">
</font></td>
</tr>
<tr>
<td height="34" colspan="4" valign="top"><font
face="Comic Sans MS" size="-1"><b>Total</b>
</font></td>
<td colspan="2" valign="top">
<input type="text" name="totalyes">
</td>
<td valign="top">
<input type="text" name="totalno">
</td>
</tr>
<tr>
<td valign="top" colspan="5" rowspan="2"><font
face="Comic Sans MS" size="-1">Note
any specific work area set-up concerns you have here:
<br>
<textarea name="concerns" cols="40"
rows="2"></textarea>
</font></td>
<td colspan="2" valign="top" height="51"> </td>
</tr>
<tr>
<td colspan="2" valign="top" height="37">
<input type="submit" name="Submit" value="Submit">
</td>
</tr>
</table>
</form>
__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com
$subst('Email.Unsub')
________________________________________________________________________
Scottish Enterprise Network
http://www.scottish-enterprise.com
Headquarters Address & Contact Numbers
150 Broomielaw
5 Atlantic Quay
Glasgow
G2 8LU.
Tel: +44 (0) 141 248 2700.
Fax: +44 (0)141 221 3217
This message is sent in confidence for the addressee only.
It may contain legally privileged information. The contents are not to
be disclosed to anyone other than the addressee. Unauthorised recipients
are requested to preserve this confidentiality and to advise the sender
immediately of any error in transmission.
|
|
 |