PDA

View Full Version : SEARCH URL QUERY OR placeholder ???


jasper77
07-29-2004, 12:25 AM
Right I don't know which name to give to my question but you will understand me and I hope help me.

Because my (cgi page) don't have the option to keep the search query in the search result template page I need your help.

Here is an example with AutoTrader.co.uk
When you click this link you go to the result page which keep the search query - in this link we search for - ALFA ROMEO 145 BETWEEN 1000 AND 5000 AND POST CODE IS w13 0np
http://atsearch.autotrader.co.uk/WWW/cars_search.asp?modelexact=1&lid=search_used_cars_full&make=ALFA+ROMEO&model=145&variant=&keywords=&min_pr=1000&max_pr=5000&mileage=&agerange=&postcode=w13+0np&miles=40&max_records=50&source=0&photo=1&sort=3&ukcarsearch_full=SEARCH

########################################

For now I can do it using javascript like here:
http://www.bodytouch.co.uk/advanced_search_result.php?keywords=Sydney

with text field - as you can see the result template parse the word "Sydney" in the search box.

I REALLY NEED YOUR HELP GUYS, I WANT TO FIND A WAY TO DO THE FIRST EXAMPLE - WITH NOT ONLY TEXT FIELD BUT - DROPDOWN, CHECKBOX...ETC.


Thanks a lot.

Grant Palin
07-29-2004, 12:41 AM
First of all, you've posted this exact same question in four (4) different subforums! That's called crossposting, and is a naughty, naughty thing to do. Read the posting guidelines! Your question seems to be cgi-related (since you mention your 'cgi page'), so I believe the Perl/CGI forum will be the best place to discuss it.

Now, it looks like a form is being posted using GET, so the input appears in the URL of the next page. The page probably then takes the value from the URL and puts it in the textbox. You probably don't need JavaScript to do this - I know you could do it with Perl of PHP or ASP.

Do you understand how GET works, how the values are added to the URL and how you can retrieve them?

Calilo
07-29-2004, 12:53 AM
not sure what you want but... if i am right, you have your search script which prints the page, and on that page you want the drop down menus and all kind of forms to remain the same as the user selected them for the search...

well if that is what you want i would say, from your cgi script when you print the page, on the drop down menus, whatsover was the user imput make the script print it as <option value="" selected>the selected one</option>.

and on the text ones, put the value the users submited by printing the $var

i mean, your script retrieves the user info and should store it in variables.
$a
$b

so say $a comes from a drop down menu, then you can do.

print "<select name="a">";
if ($a != 1) {
print "<option value="1">1</option>"; } else
print "<option value="1" selected>1</option>";
}
if ($a != 2) {
print "<option value="2">2</option>"; } else
print "<option value="2" selected>2</option>";
}
if ($a != 3) {
print "<option value="3">3</option>"; } else
print "<option value="3" selected>3</option>";
}
if ($a != 4) {
print "<option value="4">4</option>"; } else
print "<option value="4" selected>4</option>";
}


i hope im clear, but i doubt it, im getting cofused my self...

but that is what i would do, and the text forms, just print the variable in it.
hope that was it. if not let us know, not my best dont know why but im confused
Calilo