Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: RE: Radio buttons - how to set default "click ed" button based on a variable


Message #1 by Kimberly Heitzman <KHeitzman@N...> on Wed, 12 Jun 2002 11:43:24 -0500
Thanks! I think I understand the logic. Will give it a whirl.

> -----Original Message-----
> From:	Schelling, Michael [SMTP:schellim@s...]
> Sent:	Wednesday, June 12, 2002 11:38 AM
> To:	ASP Web HowTo
> Subject:	[asp_web_howto] RE: Radio buttons - how to set default
> "clicked"  button based on a variable
> 
> I haven't done this with a FOR loop. Here is how I do it for two values.
> In
> this case I have a form that calls itself. If the user did something wrong
> I
> want to redisplay the form with the values they just entered. This part of
> the code does the radio buttons. This some logic works if you are taking
> information from a database, like you mentioned. Perhaps the following
> will
> give you an idea how to incorporate the logic in your FOR loop.
> 
> <%
> ' First button
>  Career Counselor
>  If Request.Form("RegisteringAs") = "CCC" Then %>                  
>       <input name="RegisteringAs" type="Radio" value="CCC" checked>
> <% 
> Else%>
>       <input name="RegisteringAs" type="Radio" value="CCC">
> <% 
> End If%>
> 
> &nbsp;&nbsp;&nbsp;
> ' Second button
> Family Support Center Staff
> <%
> If Request.Form("RegisteringAs") = "FSC" Then %>                  
>     <input name="RegisteringAs" type="Radio" value="FSC" checked>
> <% 
> Else%>
>      <input name="RegisteringAs" type="Radio" value="FSC">
> <% 
> End If%>  
> 
> Mike
> 
> -----Original Message-----
> From: Kimberly Heitzman [mailto:kheitzman@n...]
> Sent: Wednesday, June 12, 2002 1:27 PM
> To: ASP Web HowTo
> Subject: [asp_web_howto] Radio buttons - how to set default "clicked"
> button based on a variable
> 
> 
> Greetings! 
> 
> I've written an Active Server page that displays rows of radio buttons 
> that enable managers to rate (from 1-10) the performance of their staff 
> for each of several criteria. Their selection is stored in an Access  
> database table. This is all working fine, so far. Here's the rub - the 
> next time the manager opens the page, I'd like the radio button that 
> corresponds to the selection stored in the database (the 
> variable "mrating") to be "checked". ...
> 
> 
> ---
> 
> Improve your web design skills with these new books from Glasshaus.
> 
> Usable Web Menus
> http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
> r-20
> Constructing Accessible Web Sites
> http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
> r-20
> Practical JavaScript for the Usable Web
> http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
> r-20
Message #2 by Annie Hunt <ajhunt@b...> on Wed, 12 Jun 2002 17:43:35 +0100
Here's a snippet from a stylesheet selection form I did:

<%strChecked=""
  If session("userStyle")="1" then strChecked="checked" end if%>
  <td id="1">black text, normal size</td>	
  <td><input type=radio <%if strChecked="checked" then%>checked<%end
if%>name="stylesheet" value="1" id="YellowBlackNormal">
  </td>

hth
Annie
-----Original Message-----
From: Kimberly Heitzman [mailto:kheitzman@n...]
Sent: 12 June 2002 18:27
To: ASP Web HowTo
Subject: [asp_web_howto] Radio buttons - how to set default "clicked"
button based on a variable


Greetings! 

I've written an Active Server page that displays rows of radio buttons 
that enable managers to rate (from 1-10) the performance of their staff 
for each of several criteria. Their selection is stored in an Access  
database table. This is all working fine, so far. Here's the rub - the 
next time the manager opens the page, I'd like the radio button that 
corresponds to the selection stored in the database (the 
variable "mrating") to be "checked". For example, if the user gave a 
rating of 4, I'd like the radio button corresponding to the value 4 to be 
checked the next time the form is opened. I am able to pull the rating and 
write it to the screen using Response.Write. Any way to then "check" the 
appropriate radio button?

Thanks for considering my problem.


<form name="frmRate<%=bid%>" action="rate.asp" method="post">
<input type="hidden" name="bid" value=<%=bid%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor=Black>
<font face="Verdana" size="2" color="#000000">
<%
Response.Write "Behavior ID: " & bid & "<BR>"
Response.Write "Manager Rating: " & mrating & "<P>"
			
Response.Write "<B>Manager Rating:</B><BR>"		
for i = 1 to 10
Response.Write "&nbsp;" & i & " <input name='rating' type='radio' value 
=' " & i & " '> "
next
						
%>
input type="submit" value="Save">
</form>

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
Message #3 by "Schelling, Michael" <schellim@s...> on Wed, 12 Jun 2002 12:37:36 -0400
I haven't done this with a FOR loop. Here is how I do it for two values. In
this case I have a form that calls itself. If the user did something wrong I
want to redisplay the form with the values they just entered. This part of
the code does the radio buttons. This some logic works if you are taking
information from a database, like you mentioned. Perhaps the following will
give you an idea how to incorporate the logic in your FOR loop.

<%
' First button
 Career Counselor
 If Request.Form("RegisteringAs") = "CCC" Then %>                  
      <input name="RegisteringAs" type="Radio" value="CCC" checked>
<% 
Else%>
      <input name="RegisteringAs" type="Radio" value="CCC">
<% 
End If%>

&nbsp;&nbsp;&nbsp;
' Second button
Family Support Center Staff
<%
If Request.Form("RegisteringAs") = "FSC" Then %>                  
    <input name="RegisteringAs" type="Radio" value="FSC" checked>
<% 
Else%>
     <input name="RegisteringAs" type="Radio" value="FSC">
<% 
End If%>  

Mike

-----Original Message-----
From: Kimberly Heitzman [mailto:kheitzman@n...]
Sent: Wednesday, June 12, 2002 1:27 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Radio buttons - how to set default "clicked"
button based on a variable


Greetings! 

I've written an Active Server page that displays rows of radio buttons 
that enable managers to rate (from 1-10) the performance of their staff 
for each of several criteria. Their selection is stored in an Access  
database table. This is all working fine, so far. Here's the rub - the 
next time the manager opens the page, I'd like the radio button that 
corresponds to the selection stored in the database (the 
variable "mrating") to be "checked". ...
Message #4 by "Kimberly Heitzman" <kheitzman@n...> on Wed, 12 Jun 2002 17:26:37
Greetings! 

I've written an Active Server page that displays rows of radio buttons 
that enable managers to rate (from 1-10) the performance of their staff 
for each of several criteria. Their selection is stored in an Access  
database table. This is all working fine, so far. Here's the rub - the 
next time the manager opens the page, I'd like the radio button that 
corresponds to the selection stored in the database (the 
variable "mrating") to be "checked". For example, if the user gave a 
rating of 4, I'd like the radio button corresponding to the value 4 to be 
checked the next time the form is opened. I am able to pull the rating and 
write it to the screen using Response.Write. Any way to then "check" the 
appropriate radio button?

Thanks for considering my problem.


<form name="frmRate<%=bid%>" action="rate.asp" method="post">
<input type="hidden" name="bid" value=<%=bid%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor=Black>
<font face="Verdana" size="2" color="#000000">
<%
Response.Write "Behavior ID: " & bid & "<BR>"
Response.Write "Manager Rating: " & mrating & "<P>"
			
Response.Write "<B>Manager Rating:</B><BR>"		
for i = 1 to 10
Response.Write "&nbsp;" & i & " <input name='rating' type='radio' value 
=' " & i & " '> "
next
						
%>
input type="submit" value="Save">
</form>

  Return to Index