Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    fetch and post form results to page

    I've been trying to modify this script to post the result of the form search to the same page (below the form) instead of opening a new page. So far had no luck, I tried changing newWindow=window.open to window.location = results_location;

    and also tried adding

    //load a "search results" page, using data from a form with an ID of "search""
    $.mobile.loadPage( "searchresults.php", {
    type: "post",
    data: $("form#search").serialize()
    });

    This is the original source code unedited...

    Code:
    <script language="javascript">
    <!--
    
    function netsearch(formname) 
    
    {
       var a1
       var a2
       var b1
       var b2
       var c1
       var c2
       var d1
       var d2
       var e1
       var e2
       var f1
       var f2
       var g1
       var g2
       var plus
       var TEXT
       var noENGINE
       var haveTEXT
    
    
       
       TEXT=formname.TEXT.value;
    
       noEngine=true;
       haveTEXT=true;
       plus=""
    
       if (TEXT=="")
       {
       alert("Please type in some text!")
       haveTEXT=false
       }
          else
    	  {
    	  for (var i=0; i < TEXT.length; i++)
    	     {
             if (TEXT.charAt(i)==" ")
    	        {
                plus+="%20"
                }
    	     else
    	        {
                plus += TEXT.charAt(i)
    	        }
             }
          }
       
    TEXT=plus
    
    
       //ALTAVISTA
       a1=formname.altavista.checked;
      
       a2="http://www.altavista.digital.com/cgi-bin/query?pg=q&what=web&fmt=.&q="+TEXT; 
         if (a1)
           {
           noEngine=false
           if (haveTEXT)
             {
             newWindow=window.open(a2, "av","toolbar,location,directories,status,menubar,scrollbars,resizable=1")
             }
           }
       
       //EXCITE
       b1=formname.excite.checked;
       b2="http://www.excite.com/search.gw?trace=a&search="+TEXT;  
         if (b1)
           {
           noEngine=false
           if (haveTEXT)
             {
             newWindow=window.open(b2, "e","toolbar,location,directories,status,menubar,scrollbars,resizable=1")
             }
           }  
    
       //HOTBOT
       c1=formname.hotbot.checked;
      
       c2="http://www.search.hotbot.com/hResult.html?SM=MC&MT="+TEXT+"&DV=7&RG=.com&DC=10&DE=2&OPs=MDRTP&_v=2&DU=days&SW=web&search.x=23&search.y=8";
         if (c1)
           {
           noEngine=false
           if (haveTEXT)
             {
             newWindow=window.open(c2, "h","toolbar,location,directories,status,menubar,scrollbars,resizable=1")
             }
           }  
        
       //INFOSEEK
       d1=formname.infoseek.checked;
      
       d2="http://www.infoseek.com/Titles?qt="+TEXT+"&col=WW&sv=IS&lk=noframes&nh=10";
         if (d1)
           {
           noEngine=false
           if (haveTEXT)
    	     {
             newWindow=window.open(d2, "i", "toolbar,location,directories,status,menubar,scrollbars,resizable=1")
             }
           }  
        
       //LYCOS
       e1=formname.lycos.checked;
      
       e2="http://www.lycos.com/cgi-bin/pursuit?query="+TEXT+"&matchmode=and&cat=lycos&x=33&y=10";
         if (e1)
           {
           noEngine=false
           if (haveTEXT)
             {
             newWindow=window.open(e2, "l","toolbar,location,directories,status,menubar,scrollbars,resizable=1")
             }
           }  
    
       //WEBCRAWLER
       f1=formname.webcrawler.checked;
       f2="http://www.webcrawler.com/cgi-bin/WebQuery?searchText="+TEXT;
         if (f1)
           {
           noEngine=false
           if (haveTEXT)
             {
             window.location = results_location;
    		 }
           }       
    
       //YAHOO
       g1=formname.yahoo.checked;
       g2="http://search.yahoo.com/bin/search?p="+TEXT;
         if (g1)
           {
           noEngine=false
           if (haveTEXT)
             {
             newWindow=window.open(g2, "y","toolbar,location,directories,status,menubar,scrollbars,resizable=1")
             }
           }  
    
       //noENGINE
         if (noEngine)
           {
           alert("Please select a search engine!")
           }  
    
    // END Netsearch
     
    }
    
    function getPath(url) {
    
            lastSlash = url.lastIndexOf("/")
    
            return url.substring(0, lastSlash + 1)
    
    }
    
    // -->
    
    </script>
    
    <!--
    <H2>
    This search page requires JavaScript to run. Please hit your <strong><i>BACK</i></strong> button and follow the link at the bottom of the page to get the latest version of Internet Explorer.<br /> Thank you.
    </H2>
    -->
    
    <p><br />
    <a href="http://users.ap.net/~chip" title="Back to Red Rose Int'l"><strong>Red Rose Int'l</strong></a> </p>
    
    <form name="engines" onSubmit="netsearch(engines)" method="post">
        <align="left"><p><strong>Internet Search</strong>
    
    	<br />
            
        1.&nbsp; Enter keyword(s)
    <br />
        2.&nbsp; Select search engine(s) desired <br />
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and click <strong>Search</strong>.
    <br /><br />
    
    <!-- //    <input type="text" size="25" maxlength="200" name="TEXT" value="Enter Keywords Here" onClick="form.TEXT.select()">
    // -->
    <script language="javascript">
    if (navigator.appName=="Netscape") {
       document.write("")
       document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + navigator.appName) 
       document.write("<br />");
       document.write("<input type='text' size='25' maxlength='200' name='TEXT' value='Enter Keywords Here' onFocus='form.TEXT.select()'>")
       document.write("")
       }
    else {
       document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + navigator.appName);
       document.write("<br />");
       document.write("<input type='text' size='25' maxlength='200' name='TEXT' value='Enter Keywords Here' onClick='form.TEXT.select()'> ");
        }
    </script>
    
    <br />	
        <input type="checkbox" name="altavista">Alta Vista<br />
        <input type="checkbox" name="excite">Excite<br />
        <input type="checkbox" name="hotbot">HotBot<br />
        <input type="checkbox" name="infoseek" CHECKED>Infoseek<br />
    
        <input type="checkbox" name="lycos">Lycos<br />
        <input type="checkbox" name="webcrawler">Webcrawler<br />
        <input type="checkbox" name="yahoo">Yahoo<br /> <br />
        <input type="submit" value="Search" >
    
        <input type="reset" value="Reset"> <br />
        </p>
    
    </form>
    <script>
    So what am i doing wrong? Have I missed something or am I just way off the mark?
    Last edited by jbob; 03-06-2012 at 08:54 PM.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,307
    Thanks
    23
    Thanked 612 Times in 611 Posts
    Because you want to display an HTML page in a html page the first thing you need to to do is create a iframe and position it :
    <iframe src="your search page"></iframe>
    The src="your search page" will be generated by your javascript.


  •  

    Tags for this Thread

    Posting Permissions

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