Results 1 to 2 of 2

Thread: Forms script

  1. #1

    Forms script

    Hi I am using the multiple url form script I found on your site.;

    <script language="JavaScript">
    function dosearch(document.searchform) {
    var sf=document.searchform;
    var submitto = sf.searchterms1.value + sf.search1.options[sf.search1.selectedIndex].value + sf.search2.options[sf.search2.selectedIndex].value + sf.search3.options[sf.search3.selectedIndex].value + sf.search4.options[sf.search4.selectedIndex].value +sf.search5.options[sf.search5.selectedIndex].value +sf.search6.options[sf.search6.selectedIndex].value +sf.searchterms2.value;
    window.location.href = submitto;
    return false;
    }
    </script>
    I use the script to build a search url from 5 drop downs.
    It works fine as is with one form, but I want to add one or two more single drop down forms using the same script on the same page.
    But I just cannot get it to work. As soon as I add the second one , neither work.
    I have tried the second one Identical to the first (with Dif. form name) and also as follows;

    <script language="JavaScript">
    function dosearch(document.searchform7) {
    var sf1=document.searchform7;
    var submitto1 = sf1.searchterms4.value + sf1.search7.options[sf1.search7.selectedIndex].value ;
    window.location.href = submitto1;
    return false;
    }
    </script>

    To no Avail . any help would be appreciated. Thanks Peakprod

  2. #2
    Member
    Join Date
    Jul 2005
    Location
    Four Corners, Colorado
    Posts
    3
    peakpod-

    You need to make sure that your names are different. When you copy the dosearch function change the name. You will also need to change the name in the form. (Make the form match the new dosearch):

    Code:
    <script language="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;
    }
    
    function doOtherSearch() {
    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();">
    </form>
    <form name="searchform" onSubmit="return doOtherSearch();">
    </form>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Subscribe to us on YouTube