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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enable/Disable Question

Status
Not open for further replies.

BKer

Programmer
Apr 17, 2001
62
0
0
US
I am trying to enable a disabled list box when the user clicks on a radio button. I am new to javascript and am not sure if the simple function is correct and if I am calling it right. Any help would be appreeciated.

<form name=form1 method=post action=test.asp>
<head>
<script language=&quot;javascript&quot;>
function enable(){
document.form1.cbosecondary.enabled = &quot;true&quot;;
return;
}
</script>
</head>

<form name=form1 method=post action=test.asp>
<p><font size=5>Aging Work Order Form</font><br><br>


<p>Search By</p>
<input type=radio name=shop value=&quot;ftr_description&quot; checked >Entire Shop
<input type=radio name=shop value=&quot;sh_name&quot; onclick=&quot;form1.enable();&quot;>One Trade<br>
<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;>Work Order #<br>
</form>
 
The first problem is that &quot;document.fomr1.cbosecondary&quot; doesn't exist in the document (at least not what you posted) so you will get an &quot;object expected&quot; error on that.

You do not need to attach the enable() function to an object (you may get errors from this anyway). But since you have specified that exactly one action needs to be taken when the user clicks, so you can put: onclick=&quot;enable();&quot; in that radio button tag.

Is this helpful?
 
And if you do want to enable the box the way you had originally posted, don't enclose the word, true, in quotation marks --

it's a boolean condition, not a string literal.

:)
Paul Prewett
 
Ok this is the rest of the code appended with your advice. It gives me an object expected error. Your suggestion makes sense, but I am still confused. Thanks for your help.

<head></head>
<title>Large Dollar Work Orders</title>
<form name=form1 method=post action=test2.asp>

<p><font size=5>Aging Work Order Form</font><br><br>

<p>Search By</p>
<input type=radio name=shop value=&quot;ftr_description&quot; checked >Entire Shop
<input type=radio name=shop value=&quot;sh_name&quot; onclick=&quot;enable(document.form1.cboSecondary);&quot;>One Trade<br>
<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;>Work Order #<br>
<%
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;)
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;)
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>






 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top