输入带有水印提示和提交值的文本框


Input textbox with Watermark hint and submitted value

我有一个html输入框,输入用于运行PHP脚本的值。该值也可以通过URL和GET传递。

现在我想有一个水印提示在我的文本框。我用了这位先生的密码:http://www.drewnoakes.com/code/javascript/hintTextbox.html

它工作得很好,除了如果我输入一个值并提交,文本框不显示值,而是默认提示。我更想看看它的价值。我该怎么做呢?

下面是部分代码:

<form method="get" action='index.php'>
<input type="text" name='q' SIZE="50" value="search for anything here" class="hintTextbox"> 
</form>
<?php
$Input = "";
if (isset($_GET['q'])) $Input = $_GET['q'];
try {
    script($Input);
}
catch (Exception $e) {
    print $e->getMessage();
}
?>

您可以在新浏览器或jquery插件中使用占位符属性

<form method="get" action='index.php'>
<input type="text" name='q' SIZE="50" placeholder="search for anything here" class="hintTextbox"> 
</form>