Forum Moderators: open

Message Too Old, No Replies

"FORM + SEARCH"

How do I set this Variables, and "hide" Them.

         

andmunn

5:01 am on Oct 23, 2003 (gmt 0)

10+ Year Member



Hello,

I'm running a classifieds script on my site. I need to have a "search" box, which automatically searches my entire classifieds. Now, i will show you a working configuring, which does what i want (the code below), and then show you how i want to change it - however, whenever i change it, it stops working.

<!-- WORKING CODE STARTS HERE -->
<FORM METHOD="post" ACTION="*URL OF SCRIPT GOES HERE*">
<INPUT TYPE="hidden" NAME="session_key" VALUE="">
<input name=keywords type=text size=30>
<tr>
<th align=left><font face=arial size=2>Category</font></th>
<td><SELECT NAME = "category">
<OPTION VALUE="">All<OPTION>
</select>
</td>
</tr>

<tr>
<th align=left><font face=arial size=2>Ads Must Match</font></th>
<td><SELECT NAME="boolean">
<OPTION value="any terms">any of my keywords
<OPTION value="all terms">all of my keywords
<OPTION value="as a phrase">this exact phrase
</SELECT></td>
</tr>

<tr>

<th align=left><font face=arial size=2>Display Ads As:</font></th>
<td><SELECT NAME="results_format">
<OPTION value="headlines">Headlines
<OPTION value="">Full Ads
</SELECT></td>
</tr>
<tr>
<td colspan=2>
<INPUT TYPE="hidden" NAME="query" value="advanced_search">
<INPUT TYPE = "hidden" NAME = "search_and_display_db_button"
VALUE = "Search for Matching Ads">
<INPUT TYPE = "submit" VALUE = "Search" class="button"></center>
</td></tr>
</table>
<p>
</form>
<!-- END CODE STARTS HERE -->

Now the above code works, but, i don't want *all those options*. I simply want to user to entire there keyword in the keyword text box, and then press search.

However, when i do this, it no longer works.

Also, for example, when i get rid of this:

<SELECT NAME="results_format">
<OPTION value="headlines">Headlines
<OPTION value="">Full Ads
</SELECT>

The search is automatically displayed in "full ads", instead of what i want headlines.

I know this is confusing, but here's what i want.

I want this "search" to automatically make it so that:

1. It searches "any of my keywords"
2. It searces "all categories"
3. Displays results in "headlines".

As you can see, the user can set those options above, but when i take those options away, the script either doesn't work, or doesn't diaply the way i want it.

Therefore, I need to somehow set them (i.e// set it so all categories are serached automatically), and do this in a "hidden" way, so that users can't see this selection..

Any advice?

Thanks...
Andrew.

dmorison

5:33 am on Oct 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Andrew,

You just have to have those options as hidden fields on your form; so instead of your select boxes with names "results_format", "category" and "boolean", just have hidden fields with the same names as follows;

<input type="hidden" name="boolean" value="any terms">
<input type="hidden" name="category" value="">
<input type="hidden" name="results_format" value="headlines">

andmunn

5:37 am on Oct 23, 2003 (gmt 0)

10+ Year Member



heh...
thanks!

I *know* how to do this..been scripting the page for about 4 hrs, and got my "value" and "name" values mixed up....after starring at the monitor to muhc.....

THanks for showing me what was wrong though!

Works LIKE A CHARM!

YAY!