|
Subject:
|
Enabling and Disabling form elements
|
|
Posted By:
|
socoolbrewster
|
Post Date:
|
2/18/2006 11:58:20 AM
|
I'm developing a website that has a large input form. What I want to do is disable a few form input elements that only become enabled when a user has selected another form element.
As a tester, I've been playing around with some test code I've written - but my theory doesnt work as when the code was tested in IE - I get a javascript error saying element not an object or null.
Could anyone advise me where I'm going wrong with the following simply script:
<html>
<head><title>Test Doc</title>
<script language="javascript">
function formdis(){
document.form1.box3.disabled=false;
}
</script>
</head>
<body>
<form id="form1" method="post" action="#">
<input type="text" id="box1" size="25" />
<input type="text" id="box2" size="25" onclick="formdis()" />
<input type="text" id="box3" name="box3" size="25" disabled="disabled" value="extra choice" />
</form>
</body>
</html>
Gaz
|
|
Reply By:
|
vinod_yadav1919
|
Reply Date:
|
2/18/2006 12:29:00 PM
|
Hi Socoolbrewster!!
either use <form id="form1" method="post" action="#" name="form1" > use (1) document.forms[0].box3.disabled=false; or (2) document.form1.box3.disabled=false;
with <form id="form1" method="post" action="#"> use (1) document.forms[0].box3.disabled=false;
Hope this will help you
Cheers :)
vinod
|
|
Reply By:
|
joefawcett
|
Reply Date:
|
2/18/2006 4:22:24 PM
|
Either name your form and elements using the name attribute or, if you want to access by id then use:document.getElementById("box3").disabled = false; to enable. You will need to name the elements if you wish to read the form data when it's submitted.
--
Joe (Microsoft MVP - XML)
|
|
Reply By:
|
jitendersingal
|
Reply Date:
|
2/21/2006 4:48:30 AM
|
Is it possible to show a controls enabled/disabled state using javascript?
examples:
if radiobuttonlist web control set enabled = false , in javascript cannot enable it. because radiobuttonlist generate some span tag , i cannot catch it compete. Have some javascript code suit, to wraper web control property and method.
thanks,
|
|
Reply By:
|
Greg Griffiths
|
Reply Date:
|
2/21/2006 3:45:29 PM
|
jitendersingal can you provide some more detail on your requirements ?
|