Jump to content

checkbox enable button


angel777

Recommended Posts

i tried as the below... but .. each time i click on the checkbox.. it din not appear at that second.. only appear when i click somewhere of the website..

what should i modify.. thanks

 

   <input type="checkbox" onchange="document.getElementById('submitter').disabled=''"  >

<INPUT class=button type=submit value=Sign Up name=submit id="submitter" disabled="disabled">

 

also,, after i unchecked the checkbox.. it did not disable back the button

Link to comment
https://forums.phpfreaks.com/topic/97774-checkbox-enable-button/
Share on other sites

in onchange calla javascript function , Try below code  
[code]

<input type="checkbox" name="chkBoxName" onclick="button_chk()'"  >

 

<script>

function button_chk()

{

var formName = document.formname;

  if( formName.chkBoxName.checked == true )

 

        {

 

            formName.submit.disabled=false;

        }else

        {

            formName.submit.disabled=true;

        }

}

</script>

 

<form name='formname'>

    <input type="checkbox" name='chkBoxName' onclick="button_chk()"  >

 

<INPUT class=button type=submit value=Sign Up name=submit id="submitter" disabled="disabled">

    </form>

[/code]

TRY this code  ;)

 

 

<script>
function button_chk()
{
var formName = document.formname;
  if( formName.chkBoxName.checked == true )

        {

            formName.submit.disabled=false;
        }else
        {
            formName.submit.disabled=true;
        }
}
</script>

<form name='formname'>
     <input type="checkbox" name='chkBoxName' onclick="button_chk()"  >

<INPUT class=button type=submit value=Sign Up name=submit id="submitter" disabled="disabled">
    </form>

Alright what about this?

 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>Test Page for JS</title>
	<script type="text/javascript">
		//<![CDATA[
		function toggle() {
			var el = document.getElementById('submitter');
			el.disabled = (el.disabled == true) ? false : true;
		} // End of enable
		//]]>
	</script>		
</head>
<body>
    <form action="testing.php" id="frm1" name="frm1">
		<input type="checkbox" name="check1" onchange="toggle()" />
		<input type="submit" name="submitter" id="submitter" value="Sign Up" disabled="disabled" />		    
	</form>
</body>
</html>

thanks ansarka ,lordfrikk

 

however for ,lordfrikk code.. is working... .. when i click on checkbox.. the button enabled... but when i click on reset button.. the checkbox is unchekced.. but not for the button.. it remain enabled..

 

<INPUT class=button type=reset value=Reset name=submit>

try this out....

<script type="text/javascript">

function clickme()

{

if(document.getElementById('zenag').checked==true)

{

 

document.getElementById('submitter').disabled=false;

}

else

{

 

document.getElementById('submitter').disabled=true;

}

}

</script>

</head>

 

<body><input name="zenag"  id="zenag" type="checkbox"  onchange=""  onclick="return clickme();"  >

 

<INPUT class=button type=submit value=Sign Up name=submit id="submitter" disabled="disabled">

<input type="button" value="Reload Page" onClick="window.location.reload()">

 

 

</body>

</html>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.