Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > how to reselect radio button in asp

Reply
Thread Tools

how to reselect radio button in asp

 
 
weiwei
Guest
Posts: n/a
 
      01-07-2010
Hi
I have a record input in radio button style and store in the database,
then user query it out and display in radio button style in the form.
Then if that user changes his mind and want to reselect other choice,

So far, I am reaching the last part, every time user selected another
radio button and click submit, I still see the old radio button result
instead of new one.

Any idea??? (below is my example code)
thanks in advance

First page to select radio button and hit submit

<td class="cat">Quickly builds rapport and identifies customer’s
needs in order to book rental.</td>

<td class="catc"><input type="radio" name="num1" value="1" /></td>

<td class="catc"><input type="radio" name="num1" value="2" /></td>

<td class="catc"><input type="radio" name="num1" value="3" /></td>

<td class="catc"><input type="radio" name="num1" value="4" /></td>

<td class="catc"><input type="radio" name="num1" value="5" /></td>

</tr>



Second page I pick it up the variable and do a select case statement,
if user chose choice 1 and it will show up as choice 1. now if user
change mind and want to change to choice 2, I can do it from it
screen, and click submit, I will getting choice 1 instead of new
choice 2



<% strnum1 = request.form(“num1”) %>

<% Select Case strnum1 %>

<% Case 1 %>

<td class="catc"><input type="radio" name="num1" value="1" Checked /></
td>

<td class="catc"><input type="radio" name="num1" value="1" /></td>

<td class="catc"><input type="radio" name="num1" value="1" /></td>

<td class="catc"><input type="radio" name="num1" value="1" /></td>

<td class="catc"><input type="radio" name="num1" value="1" /></td>

<% case 2 %>

<td class="catc"><input type="radio" name="num1" value="2" /></td>

<td class="catc"><input type="radio" name="num1" value="2" Checked /></
td>

<td class="catc"><input type="radio" name="num1" value="2" /></td>

<td class="catc"><input type="radio" name="num1" value="2" /></td>

<td class="catc"><input type="radio" name="num1" value="2" /></td>

</ End Select %>
 
Reply With Quote
 
 
 
 
Adrienne Boswell
Guest
Posts: n/a
 
      01-07-2010
weiwei <(E-Mail Removed)> wrote in news:f6feaa4b-c19c-409e-ac26-
http://www.velocityreviews.com/forums/(E-Mail Removed):

> Hi
> I have a record input in radio button style and store in the database,
> then user query it out and display in radio button style in the form.
> Then if that user changes his mind and want to reselect other choice,
>
> So far, I am reaching the last part, every time user selected another
> radio button and click submit, I still see the old radio button result
> instead of new one.
>
> Any idea??? (below is my example code)
> thanks in advance
>
> First page to select radio button and hit submit
>
> <td class="cat">Quickly builds rapport and identifies customer’s
> needs in order to book rental.</td>
>
> <td class="catc"><input type="radio" name="num1" value="1" /></td>
>
> <td class="catc"><input type="radio" name="num1" value="2" /></td>
>
> <td class="catc"><input type="radio" name="num1" value="3" /></td>
>
> <td class="catc"><input type="radio" name="num1" value="4" /></td>
>
> <td class="catc"><input type="radio" name="num1" value="5" /></td>
>
> </tr>
>
>
>
> Second page I pick it up the variable and do a select case statement,
> if user chose choice 1 and it will show up as choice 1. now if user
> change mind and want to change to choice 2, I can do it from it
> screen, and click submit, I will getting choice 1 instead of new
> choice 2
>
>
>
> <% strnum1 = request.form(“num1”) %>
>
> <% Select Case strnum1 %>
>
> <% Case 1 %>
>
> <td class="catc"><input type="radio" name="num1" value="1" Checked />

</
> td>
>
> <td class="catc"><input type="radio" name="num1" value="1" /></td>
>
> <td class="catc"><input type="radio" name="num1" value="1" /></td>
>
> <td class="catc"><input type="radio" name="num1" value="1" /></td>
>
> <td class="catc"><input type="radio" name="num1" value="1" /></td>
>
> <% case 2 %>
>
> <td class="catc"><input type="radio" name="num1" value="2" /></td>
>
> <td class="catc"><input type="radio" name="num1" value="2" Checked />

</
> td>
>
> <td class="catc"><input type="radio" name="num1" value="2" /></td>
>
> <td class="catc"><input type="radio" name="num1" value="2" /></td>
>
> <td class="catc"><input type="radio" name="num1" value="2" /></td>
>
> </ End Select %>



This is how I do things like this. First of all, almost all forms I do
post to themselves, and avoid these kind of issues. You are also using
XHTML syntax which required that all attributes have values, eg:
checked="checked" is valid, while just checked is not. That might also
have something to do with it.

<% num1 = request.form("num1") %>

<input type="radio" name="num1" value="1" <% if num1="1" then%>
checked="checked"<%end if%> />


or you can use a function:

<input type="radio" name="num1" value="1" <%=chkchkd(1,num1)%> />

<%
function chkchkd(value,selected)
if value = selected then
chk = "checked=" & chr(34) & "checked" & chr(34)
else
chk = ""
end if

chkchkd = chk
end function
%>

heck, you can even put it through a loop:

<% for i = 1 to 5 %>
<input type="radio" name="num1" value="<%=i%>" <%=chkchkd(i,num1)%> />
<% next%>

--
Adrienne Boswell at work
Please respond to the group so others can share
nextBlock.com
http://nextblock.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Align Radio Button text and button tshad ASP .Net 6 11-26-2009 08:52 AM
ASP.NET Reset Radio Button in a group of Radio Buttons Scott D Johnson ASP .Net 1 09-27-2006 10:38 PM
Please help me reselect dropdown on page reload Jedi Knight Javascript 0 07-19-2005 05:13 PM
Radio button List problem: How to find value of Radio button list's Selected Item using javascript?? Hiten ASP .Net Web Controls 1 05-26-2004 10:32 AM



Advertisments