I am tring to use HTML tags checkbox and textbox along with PHP.
When the checkbox is not checked,the textbox is disable.But when I checked the check box,the textbox should become enabled.

How can i do this?

Here is My code:-

<html>
<head> THIS IS TEST
<title> TEST </title>
</head>
<form>
<body>
 CHECK BOX <input type="checkbox" name="htmlchk" value="chk"id="chk"><br>
 TEXT BOX  <input type="text" id="txt"disabled="True">
<?php
 if($chk.CHECKED=="true")
 {
  $txt.disable="False"
 }
?>
</body>
</form>
</html>

Please help me as soon as possible.

Recommended Answers

All 3 Replies

This is something you will want to do with JavaScript.

<html>

<head>
<script language="javascript">
function checkState()
{
    document.testform.tf1.disabled = !document.testform.tf1.disabled;
}
</script>
</head>

<body>

    <form name="testform">
          <input name="cb1" value="test" type="checkbox" onClick="checkState()"> 
        <input name="tf1" value="test2" type="textfield" disabled="true">
    </form>
</body>
</html>

Thanks Phaelax,
I got the code sent by you. And now my problem has been solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.