www.webdeveloper.com
Results 1 to 4 of 4

Thread: Javascript Search Query Question

  1. #1
    Join Date
    Dec 2009
    Posts
    6

    Javascript Search Query Question

    I have noooo idea if I am even posting this in the correct area, let alone the correct site. If not I apologize and maybe someone could direct me elsewhere.
    I am trying to add a custom search into my site.

    http://www.jeffknowsloans.com

    you can see it about the middle of the page.

    I am using the following script to do so.

    Code:
    <script type="text/javascript">
    function dosearch() {
    var sf=document.searchform;
    var submitto = sf.sengines.options[sf.sengines.selectedIndex].value + escape(sf.searchterms.value);
    window.location.href = submitto;
    return false;
    }
    </script>
    <form name="searchform" onSubmit="return dosearch();">
    Select County
    <select name="sengines">
    <option value="http://www2.co.washington.mn.us/opip/mod/addresssrch/result.asp?housenum=&street=" selected>Washington</option>
    <option value="http://rrinfo.co.ramsey.mn.us/public/characteristic/PropertySearchResults.aspx?pin=&Nbr=&Street=&pg=1" selected>Ramsey</option>
    <option value="http://www.altavista.com/web/results?q=">Alta Vista</option>
    <option value="http://www.dogpile.com/info.dogpl/search/web/">Dogpile</option>
    </select>
    Street Address:
    <input type="text" name="searchterms">
    <input type="submit" name="SearchSubmit" value="Search">
    </form>
    here is the problem i am running into.
    I dont know how to ignore or add certain parts of the search when it sends. for example. take a look at

    Code:
    <option value="http://rrinfo.co.ramsey.mn.us/public/characteristic/PropertySearchResults.aspx?pin=&Nbr=&Street=&pg=1" selected>Ramsey</option>
    When i try to do a search under this drop down selection it doesnt work. because it needs the &pg=1 to be added to the users request.
    Meaning if I set it to
    they type in their street name and the street name inputs into the search query but it wont fully work because it doesnt add the &pg=1 after it all.
    how in the world do I get it to add things like that?

    another example

    taking a look at

    Code:
    <option value="http://www2.co.washington.mn.us/opip/mod/addresssrch/result.asp?housenum=&street=" selected>Washington</option>
    this search function should technically be
    Code:
    <option value="http://www2.co.washington.mn.us/opip/mod/addresssrch/result.asp?" selected>Washington</option>
    however since i dont know how to add certain functions to the search i have to skip the housenum option. that means my customers cant search by street number. I want them to be able to type in their house number and their street address and it will change to what each seperate (outside) search engine needs.

    Does this make any sense at all?

  2. #2
    Join Date
    Jan 2004
    Location
    Washington DC
    Posts
    1,107
    Why not just do:

    Code:
    <form name="searchform" action="http://www2.co.washington.mn.us/opip/mod/addresssrch/result.asp?housenum=&street=">
    	<select name="sengines" onchange="this.form.action=this.options[this.selectedIndex].value">
    		<option value="http://www2.co.washington.mn.us/opip/mod/addresssrch/result.asp?housenum=&street=" selected>Washington</option>
    		<option value="http://rrinfo.co.ramsey.mn.us/public/characteristic/PropertySearchResults.aspx?pin=&Nbr=&Street=&pg=1" selected>Ramsey</option>
    		<option value="http://www.altavista.com/web/results?q=">Alta Vista</option>
    		<option value="http://www.dogpile.com/info.dogpl/search/web/">Dogpile</option>
    	</select>
    	<input type="text" name="searchterms">
    	<input type="submit" name="SearchSubmit" value="Search">
    </form>

  3. #3
    Join Date
    Dec 2009
    Posts
    6
    maybe i should rephrase myself.

    I have noooo idea if I am even posting this in the correct area, let alone the correct site.
    on a scale of 1-100 when it comes to java and scripting stuff for websites. Im at about a 7.
    so much so that i have no idea what your reply even changes.

    each website im sending a search out to uses different query lines for their own database searches.
    the washington county one uses housenum= while ramsey county uses Nbr= even though they both mean the same thing (a house number).
    So the information to send out to these sites is going to be different. I need to know how to only have 2 text input fields while on the back end changing what is sent out to each outside site when the user picks a different selection off the drop down box.
    i need to know how to change queries on the back end.

    I did find it I change

    Code:
    House Num:
    <input type="text" name="searchterms">
    <input type="submit" name="SearchSubmit" value="Search">
    to

    Code:
    House Num: <input type="text" name="housenum" />
    that it does add that housenum to the query. but my entire links and all get messed up and look like this then...

    http://jeffknowsloans.com/?sengines=...hSubmit=Search

    god am i lost....

  4. #4
    Join Date
    Dec 2009
    Posts
    6
    well i found out i can use

    Code:
    if (sf.sengines.options[sf.sengines.selectedIndex].value == "Ramsey") {
       submitto = "http://rrinfo.co.ramsey.m...pin=&Nbr=&Street=" + escape(sf.searchterms.value) + "&pg=1";
    but it still wont open to the correct page.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles