14.4 Accessing Forms

In addition to obtaining documents with <fetch> , Vortex has the ability to submit documents with <submit> . This function takes a URL to a form and some variables, and submits the form with the variables. The results are then returned as with <fetch> .

This provides the ability to easily query complex forms on the Web. For example, let's say some other site on the Web has a form that lets users search various news archives:


  <FORM METHOD=post ACTION=http://www.search-o-rama.com/search>
    Query:         <INPUT NAME=q SIZE=20>
    What database:
     <SELECT NAME=db>
       <OPTION VALUE=cur SELECTED>Current
       <OPTION VALUE=old>Last month's
     </SELECT>
  </FORM>

We find this site useful, so we'd like to let our users search it, but in combination with our own site, and we want to display the results together. We can do that with a script like this:


  <SCRIPT LANGUAGE=vortex>

  <A NAME=main>
    <FORM METHOD=post ACTION=$url>
      Enter your query: <INPUT NAME=query SIZE=20>
      <INPUT TYPE=submit>
    </FORM>
    <IF $query neq "">
      Results from my site: <P>
      <SQL MAX=10 "select Title from mytbl where Body likep $query">
        $Title <BR>
      </SQL>
      <P> Results from search-o-rama: <P>
      <urlcp timeout 10>
      <urlcp reparentmode abs>
      <submit METHOD=post URL="http://www.search-o-rama.com/search"
        q=$query db="cur">
      <send $ret>
    </IF>
  </A>

  </SCRIPT>

(next page):

Back: Controlling Fetch Behavior Next: Accessing Forms - Continued
Copyright © 2024 Thunderstone Software LLC. All rights reserved.