This is not a perl question it is a javascript question. Anyway here is how to do it using the XMLHTTP object. It is pretty easy. All we do is link our submit button to a js function. This function returns false (as with input validation when there is an error) so the form does nothing when it returns. The function groks the search string, assembles the GET request, sends it, and dumps the data into the div. Jobs done.

As a side note the search CGI needs work. If you search for 'a' it will dump 40,000+ results into the browser, if you type 'b'....and by the time you get to 'z' the entire DB has been extracted. If you type '*' it will tell you why. You probably don't want that to be happening.

<html> <head> <script type="text/javascript"> var xmlhttp; // need this global to deal with bug issue function loadXMLDoc(url,responseHandler,async) { xmlhttp = null; if (window.XMLHttpRequest) { // code for Firefox, Opera, IE7 xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp != null) { xmlhttp.onreadystatechange = responseHandler; xmlhttp.open("GET",url,async); xmlhttp.send(null); } else { alert("Your browser does not support XMLHTTP."); } } function updateSearch() { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { document.getElementById('results').innerHTML = xmlhttp.res +ponseText; xmlhttp.close; } else { alert("Problem retrieving data:" + xmlhttp.statusText); } } } function doSearch() { var search = escape(document.searchform.Search_Term.value); var url = "http://cgi.mercury-soft.com/cgi/mercury-soft.com/user-c +gi-bin/passport/passport.cgi"; url = url + "?Formaction=Searchforword&Search_Term="+search+"&B=Ye +s&x=1&y=1"; loadXMLDoc(url,updateSearch,false); return false; } </script> </head> <form name="searchform"> <input type="text" name="Search_Term"> <input type="button" value="Submit Form" onClick="doSearch()"> </form> <div id="results"> No results. </div> </body> </html>

In reply to Re: Printing html search results to the same page <div> by tachyon-II
in thread Printing html search results to the same page <div> by ianshortreed

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.