最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Input textbox with Watermark hint and submitted value - Stack Overflow

programmeradmin2浏览0评论

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: .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($Input);
}
catch (Exception $e) {
    print $e->getMessage();
}
?>

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./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($Input);
}
catch (Exception $e) {
    print $e->getMessage();
}
?>
Share Improve this question asked Apr 24, 2011 at 9:07 Timothée HENRYTimothée HENRY 14.6k22 gold badges98 silver badges138 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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>
发布评论

评论列表(0)

  1. 暂无评论