PDA

View Full Version : using a textbox result in an URL


Ricky158
11-03-2002, 03:51 AM
yes, yes, i am back with another problem.

i want to have a text box on my site, and the user types in the item they want to look for. they click an "Ok" button and they do a search on ebay for what they typed in the text box.

here's the beggining of the ebay URL: "http://search.ebay.com/search/search.dll?cgiurl=http%3A%2F%2Fcgi.ebay.com%2Fws%2F&krd=1&from=R8&MfcISAPICommand=GetResult&ht=1&SortProperty=MetaEndSort&query=[insert result from text box here]"

basically, i just need to put whatever the user types in the text box, between those brackets at the end (no brackets in actual URL). also if there are any spaces, it should come up as "+"'s in the URL. for example, if someone types in "cat food" in the text box, it will have the normal ebay url given above, and at the end it will say "...&query=cat+nip"

as always, any and all help is greatly appreciated.

THANKS!

chrismiceli
11-03-2002, 06:42 AM
to add to a url you could do something like this

parent.location = "www.ebay.com/query=" + document.forms[0].elements[0].value + ".php"

i don't know the real ebay search way but that might be of some help.

boywonder
11-03-2002, 03:21 PM
<script language="JavaScript" type="text/javascript">
<!--
function goEbay(val){
val = val.replace(/^\s+/,"").replace(/\s+$/,"").replace(/\s+/g,"+");
window.location = "http://search.ebay.com/search/search.dll?cgiurl=http%3A%2F%2Fcgi.ebay.com%2Fws%2F&krd=1&from=R8&MfcISAPICommand=GetResult&ht=1&SortProperty=MetaEndSort&query=" + val;
}
//-->
</script>

<form name="frm">
<input type="text" name="qry" value="">
<br>
<input type="button" value="go" onclick="goEbay(this.form.qry.value)">
</form>

Ricky158
11-03-2002, 03:27 PM
wooohooo! thanks boywonder, that one worked.

i did "View Source" at the eBay site and i pin-pointed that search thing. but i copied it into my HTML editor, and the "Find It" button didnt work. i was just about ready to post the new problem here, when along came a script that works! thanks!!

boywonder
11-03-2002, 03:31 PM
youre welcome :)

GCrame5832
12-25-2005, 03:48 AM
<script language="JavaScript" type="text/javascript">
<!--
function goEbay(val){
val = val.replace(/^\s+/,"").replace(/\s+$/,"").replace(/\s+/g,"+");
window.location = "http://search.ebay.com/search/search.dll?cgiurl=http%3A%2F%2Fcgi.ebay.com%2Fws%2F&krd=1&from=R8&MfcISAPICommand=GetResult&ht=1&SortProperty=MetaEndSort&query=" + val;
}
//-->
</script>

<form name="frm">
<input type="text" name="qry" value="">
<br>
<input type="button" value="go" onclick="goEbay(this.form.qry.value)">
</form>when i try that, all it does is goes in the address bar of the current site.

GCrame5832
05-15-2006, 06:57 AM
I want to put a search box on my website for users to look up words at dictionary.com. does anyone know the code? What about a weather search at weather.com too? two different fields of course