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

Disable form element using javascript

Status
Not open for further replies.

CHRISWYA

IS-IT--Management
Sep 14, 2004
19
GB
I think this should be a simple piece of javascript but am unsure of the correct syntax to disable a form element using javascript as i have never come across it. Any advice would be gratefully received.


if(theForm.p_close_date.value!=0)
{
p_close_date=disabled
{
return false;
}
}
 
doesn't seem to work thanks for the advice though
 
Hmmm. I made up a little test that's working for me (tested in IE6 and Mozilla 1.7.2). Does it work for you?

Code:
<script type="text/javascript">

function test() {

	document.getElementById("test").disabled = true
}

</script>

<input type="text" id="test" />

<a onclick="test();">test</a>
 
Code:
...
var e = document.forms['theForm'].elements['p_close_date'];
if(e.value != 0) {
    e.disabled = true;
}
return false;
...

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top