Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio Button on Submit

Status
Not open for further replies.

BKer

Programmer
Apr 17, 2001
62
US
I am having trouble with having a radio button stay in the same position when the form Iam using submits to itself. When it submits the radio buttons go back to their default positions. I also have a radio button that enables a drop down menu, but again when the form submits to itself the drop down is disabled. Here is the code. I am sure it is easy but it is frustrating me. Thanks for the help.

<form name=form1 method=post action=test.asp>
<head>
<script language=&quot;javascript&quot;>
function disabling(){
if (document.form1.radShop[0].checked=true){
document.form1.cboSecondary.disabled= true;
}
return;
}
function enabling(){
if (document.form1.radShop[1].checked=true){
document.form1.cboSecondary.disabled= false;
}
return;
}
</script>
</head>
<p><font size=5><em><b>Aging Work Order Form</b></em></font>

<hr>
<p>Search By</p>
<input type=radio name=radShop value=&quot;ftr_description&quot; checked onclick=&quot;disabling();&quot;>Entire Shop
<input type=radio name=radShop value=&quot;sh_name&quot; onclick=&quot;enabling();&quot;>One Trade

<P>Sort By</P>
<input type=radio name=sort value=&quot;wo_request_date&quot; checked>Date
<input type=radio name=sort value=&quot;wo_number&quot; onClick=&quot;form1.submit()&quot;>Work Order #


<%
set conn=server.CreateObject(&quot;adodb.connection&quot;)
set objrs=server.CreateObject(&quot;adodb.recordset&quot;)
conn.Open(&quot;DRIVER={Microsoft ODBC for Oracle};SERVER=;UID=;PWD=&quot;)
sql= &quot;select distinct ftr_description, wk_title, wk_start_date, wk_last_name, wk_first_name, wk_id_code from f_trades, f_personnel where wk_ftr_fk = ftr_pk and wk_active = 'YES'&quot;

objRS.Open &quot;select sh_name from f_shops&quot;, conn
if Request(&quot;cboPrimary&quot;) = &quot;&quot; then
shop= objRS(&quot;sh_name&quot;)
shopX = shop
else
shop = Request(&quot;cboPrimary&quot;)
end if


%>

<p>
<select name=cboPrimary size=1 onChange=&quot;form1.submit();&quot; >
<%while not objRS.EOF
varShop = objRS(&quot;sh_name&quot;)%>
<option value=&quot;<%=varShop%>&quot; <%if shop = varShop then Response.Write &quot; SELECTED&quot;%>><%=objRS(&quot;sh_name&quot;)%>
<%
objRS.MoveNext
wend
objRS.Close
objRS.Open &quot;select ftr_description from f_trades, f_shops where ftr_sh_fk = sh_pk and sh_name = '&quot; & shop &&quot;'&quot;, conn
%>
</select>
</p>
<p>
<select name=cboSecondary size=1 disabled>
<%
while not objRS.EOF
varShop = objRS(&quot;ftr_description&quot;)%>
<option value=&quot;<%=varShop%>&quot;><%=objrs(&quot;ftr_description&quot;)%>
<% objRS.MoveNext
wend
objRS.Close
set objRS.ActiveConnection = nothing
set objRS = nothing
%>
</select>
</form>

<form name=form2 method=post action=&quot;testwo.asp&quot;>
<%if request(&quot;sort&quot;) = &quot;&quot; then
newsort = &quot;wo_request_date&quot;
else
newSort = request(&quot;sort&quot;)
end if
Response.Write (newsort) %>
<input type=hidden name=&quot;shopx&quot; value=&quot;<%=shopx%>&quot;>
<input type=hidden name=&quot;cboprimary&quot; value=&quot;<%=shop%>&quot;>
<input type=hidden name=&quot;cbosecondary&quot; value=&quot;<%=varshop%>&quot;>
<input type=hidden name=&quot;sort&quot; value=&quot;<%=newsort%>&quot;>
<input type=submit id=submit1 name=submit1 action=&quot;testwo.asp&quot;>

</form>
 
I see that it's submitting to an asp page, and that's a good thing. :)

just check the values as they come in and check or uncheck them based on those values like:

<%
if request.form(&quot;radio1&quot;) = checkedValue then
response.write(&quot;<input type=radio name=radio1 value=checkedValue checked>&quot;)
else
response.write(&quot;<input type=radio name=radio1 value=checkedValue>&quot;)
end if
%>

or something to that effect, where they keep their state.

:)
Paul Prewett
 
I understand waht you were getting at, but I get an error on the response.write(radio) it has a problem with the value attribute of radio and says missing ')', but when I take that out the value it at least prints a radio button, but has no associated value. Any ideas? Thanks for the help too.
 
I'm having a hard time getting a mental picture of the line of code where you're trying to write the radio button, and why it would be throwing an error. Post it (just the excerpt) and let's take a peek.

:)
 
It boggles me not just because I am new to this, but it doesn't make sense that when I take out the value it works. Tahnks again for your help. The error again is expected ')' on the first response.write

<%if Request(&quot;sort&quot;) = &quot;&quot; then
Response.Write(&quot;<input type=radio name=sort value=&quot;wo_request_date&quot; checked>Date&quot;)
Response.Write(&quot;<input type=radio name=sort value=&quot;wo_number&quot; >Work Order #<br>&quot;)
else
Response.Write(&quot;<input type=radio name=sort value=&quot;wo_request_date&quot;>Date&quot;)
Response.Write(&quot;<input type=radio name=sort value=&quot;wo_number&quot; checked>Work Order #<br>&quot;)
%>
 
Yes, notice where you have put in extra double quotes... it's getting confused right there and expecting the end of the statement...

Response.Write(&quot;<input type=radio name=sort value=&quot;wo_request_date&quot; checked>Date&quot;)

should be:

Response.Write(&quot;<input type=radio name=sort value=&quot;&quot;wo_request_date&quot;&quot; checked>Date&quot;)

But just as a note, you don't even need the quotes at all, really... it would work just fine without them.

And don't forget to fix them in the other spots, too.

good luck! :)
paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top