How to disable text field or input if a value is present?
I am trying to pull the value(which works) and disable the field from input(which will NOT work) and post it. Thanks in advance.
Here is my code below:
<textarea name="title" id="title"><?php
$query = "SELECT * FROM table WHERE id = '$member'";
$result = mysql_query($query);
$member = mysql_real_escape_string($member);
while($row = my开发者_如何学Csql_fetch_array($result)) {
$title = $row['title'];
echo $title;
}?> <?=($disable ? " disabled=\"disabled\"" : "");?>
<?php if($title == true) {
$disable = true;
}
else {
$disable = false;
}
?></textarea>
I'm not sure if you're trying to disable it based on query results (which it looks like what you're trying to do). You're closing the textarea
opening tag before setting the disabled attribute. The disabled
attribute has to be an attribute of the textarea
tag:
<textarea disabled="disabled"></textarea>
精彩评论