Forum Moderators: open

Message Too Old, No Replies

How to Enable and Disable File Property using Radio button

Code given below is not Working.

         

srins

12:33 pm on Jul 25, 2008 (gmt 0)

10+ Year Member



Hi,

I was trying to Enable/Disable File text Property using radio button selected option by java script.

But i am gettint Error as ,

Getttin Error as document.forms.0.theFile is null or not an object

I am using Struts framework.

<code>
<tr>
<td width=50%>
<html:radio property="Result"
value="results from tool "
onclick="disableTextField()">Results from tool </html:radio>
</td>
<td width=50%>
<html:radio property="Result"
value="results from not tool"
onclick="enableTextField()">Results from non-existing tool </html:radio>
</td>
</tr>
<tr>
<td width=25%>
<b>Template File: </b><span class="warning">*</span>
</td>
<td width=75%>
<html:file property="theFile" disabled="true" />
&nbsp;&nbsp;&nbsp;
</td>
</tr>

function enableTextField()
{
var form = document.forms[0];
alert("form"+form);
document.forms[0].theFile.disabled = "false";
}

function disableTextField()
{
var form = document.forms[0];
alert("form"+form);
document.forms[0].theFile.disabled = "true";
}
<code>

I am getting as,

Getttin Error as document.forms.0.theFile is null or not an object

If i click the Results from non-existing tool radio option it should enbale the theFile property ie.Browse button of Upload Template File.

If i should click on Results from tool it should disable the Browse button of Upload Template file.

Also,By default radio button with value "Results from tool" should be checked.

Can someone help me in this regard.

Thanks,
Srins.

Fotiman

2:14 pm on Jul 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What is the generated HTML? Please post that instead.

Also, in your enableTextField and disableTextField methods, don't quote "false" and "true". They should be false and true instead.