Hi,

I need to discuss some problems regarding handling of text boxes using php which are as follows:

  1. Can we set focus of a text box when an if condition is true in php?
  2. Can we disable a text box when an if condition is true in php? I need to disable and enable the text box based on some true and false conditions.

Thanks.
Regards,

Answer is Yes to both the questions.

<html>
<body>
<form name='test' method='post'>
<input type='text' id='name' name='name'>
<input type='text' id='age' name='age'>
</form>
<?php
 $value = 1;
 if($value == 1) {
 	echo "<script>document.getElementById('age').focus();</script>";
 	echo "<script>document.getElementById('name').disabled=true;</script></script>";
 }
?>
</body>
</html>

Thanks for your reply. But if I dont want to use java script then how it can be possible?

It's ok. Thanks for your time. The problem is resolved. It will be:

<input type="text" name="ch1" <? if( $_GET["e"] == 1) echo 'disabled';?> />
This question has already been answered. Start a new discussion instead.