Input textbox with Watermark hint and submitted value
I have an html Input box to enter value used to run a PHP script. The value can also be passed using the URL and GET.
Now I would like to have a watermark hint in my textbox. I used the code from this gentleman: http://www.drewnoakes.com/code/javascript/hintTextbox.html
It works fine except that if I enter a value and submit the textbox does not show the value but the default hint. I would like to see the value instead. How can I do that?
Here is partial code:
<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($I开发者_JAVA百科nput);
}
catch (Exception $e) {
print $e->getMessage();
}
?>
You can user placeholder attribute in new browsers or placeholder jquery plugin
<form method="get" action='index.php'>
<input type="text" name='q' SIZE="50" placeholder="search for anything here" class="hintTextbox">
</form>
精彩评论