javascript+form+search problem...
Posted: Sun Apr 06, 2003 8:58 am
In "form" part I added...
And "search..." is always in the search box..when you want to search something you just click on it and it becomes blank...
But there is the problem when you write nothing in search box form and then push the search button...you will get the search result with "search..." or any other word you write it down in that form part...
so..huh...my question is...
how to "block" searching and to get echo "<p>Please enter a search...</p>";
no matter is there nothing in search form box or where are my value="search..." onfocus="value=''" is in it..
p.s.
onfocus="value=''"
is
onfocus="value=' ' "
Code: Select all
<form name="form" action="search.php" method="get">
<input type="text" name="q" />
<input type="text" name="q" value="search..." onfocus="value=''" size="16" height="20" />
</form>
<?php
// Get the search variable from URL
$var = @$_GETї'q'] ;
$trimmed = trim($var); //trim whitespace from the stored variable
// check for an empty string and display a message.
if (($q == "") && ($q == "Search..."))
{
echo "<p>Please enter a search...</p>";
exit;
}
// check for a search parameter
if (!isset($var))
{
echo "<p>We dont seem to have a search parameter!</p>";
exit;
}And "search..." is always in the search box..when you want to search something you just click on it and it becomes blank...
But there is the problem when you write nothing in search box form and then push the search button...you will get the search result with "search..." or any other word you write it down in that form part...
so..huh...my question is...
how to "block" searching and to get echo "<p>Please enter a search...</p>";
no matter is there nothing in search form box or where are my value="search..." onfocus="value=''" is in it..
p.s.
onfocus="value=''"
is
onfocus="value=' ' "