I have a form with a checkbox and two buttons named submitt and continue.i want to disable the submitt button and enable the continue button at the same time when one clicks the checkbox. My form is:
<form name="apply">
<input type="checkbox" onClick="document.apply['submitt'].disabled =(document.apply['submitt'].disabled)? false : true" >
<input type="submit" id="submit" name="submitt" value="Submit Application" class="button" disabled>
<input type="button" name="continue" value="continue" id="continue" disabled/>
</form>
pls help ????
Enable a button in javascript
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Enable a button in javascript
It should be disabled="disabled" (http://www.w3schools.com/tags/att_input_disabled.asp)
Call a function in your onclick. Something like this:
Call a function in your onclick. Something like this:
Code: Select all
<script type="text/javascript">
function submit_disable_toggle(){
if (document.all || document.getElementByid){
document.apply.submitt.disabled = !document.apply.submitt.disabled;
}
}
</script>(#10850)
Re: Enable a button in javascript
Thanks Christopher..it worked nice when calling a function on onclick. Final code is:
<html>
<head>
<script type="text/javascript">
function submit_disable_toggle()
{
document.apply['submitt'].disabled =(document.apply['submitt'].disabled)? false : true;
document.apply['continue'].disabled =(document.apply['submitt'].disabled)? false : true;
}
</script>
</head>
<body>
<form name="apply">
<input type="checkbox" id="check" onClick="submit_disable_toggle()">
<input type="submit" id="submit" name="submitt" value="Submit Application" class="button" >
<input type="button" name="continue" value="continue" id="continue" disabled="disabled"/>
</form>
</body>
</html>
<html>
<head>
<script type="text/javascript">
function submit_disable_toggle()
{
document.apply['submitt'].disabled =(document.apply['submitt'].disabled)? false : true;
document.apply['continue'].disabled =(document.apply['submitt'].disabled)? false : true;
}
</script>
</head>
<body>
<form name="apply">
<input type="checkbox" id="check" onClick="submit_disable_toggle()">
<input type="submit" id="submit" name="submitt" value="Submit Application" class="button" >
<input type="button" name="continue" value="continue" id="continue" disabled="disabled"/>
</form>
</body>
</html>