how to reselect radio button in asp

W

weiwei

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 %>
 
A

Adrienne Boswell

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%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top