Re: HTML, links in forms

Craig R. McClanahan (crm@perpetua.dat.com)
Thu, 18 May 1995 16:56:34 +0800


Date: Thu, 18 May 1995 16:56:34 +0800
From: crm@perpetua.dat.com (Craig R. McClanahan)
Message-Id: <9505182356.AA18678@perpetua.dat.com>
To: cdackus@knoware.nl
Cc: www-html@www10.w3.org
In-Reply-To: <9505181131.AA12045@indy.knoware.nl> (cdackus@knoware.nl)
Subject: Re: HTML, links in forms

>>>>> "Christian" == Christian Dackus <cdackus@knoware.nl> writes:

    Christian> I was wondering, for a week I went to visit a big dutch
    Christian> publishing business. They are on the web too
    Christian> (http://vnu.ib.com). Our firm has been bought by this
    Christian> so called VNU.

    Christian> What I saw there was a demonstration via Netscape, of
    Christian> some magazines they are planning to publish online very
    Christian> soon. The lay-out was like this:

    Christian>
    Christian> Index: Pull-down menu with all the chapters/articles


    Christian> Very nice, but the interesting thing was, that by
    Christian> choosing one option of the pull-down menu, the browser
    Christian> skipped to the requested chapter.

I tried to access this page, but the host never answered -- so I don't know
for sure what they did.  However, I can conceive of how you might create this
kind of visual appearance using image maps.  This is a technique that displays
an image with the ISMAP attribute.  The client browser then lets the user click
on the image someplace (probably on what looks like the menu bar), and sends
back to the host the mouse coordinates (relative to the corner of the image)
where the click occurred.  Thus, if your image had a line that looked like the
Netscape menu bar:

    ________________________________________________________________________
   |                                                                        |
   | File    Edit    View    Go    (and so on ...)                          |
   |                                                                        |
    ------------------------------------------------------------------------

Then, if the user clicked somewhere near the word "Edit", it would send back
the coordinates to a script.  The script would figure out which "option" was
"selected", and send back a new image that has the same menu bar at the top,
plus the opened "Edit" menu, listing all of the options.

You could extend this technique to do a pretty good imitation of a menu bar's
user interface, simply by having a separate image file for each possible state,
and a script smart enough to figure out which image to display next.

For more info on image maps, you can consult one of the many online HTML
references (I always start at the NCSA home page when looking for stuff like
this).  You'll probably also need to review how to set up executable scripts,
which should be discussed in the docs for whatever HTTPD server you're running.
A common standard for interfacing between an HTTPD server and your script is
called the Common Gateway Interface (CGI) standard.  On a UNIX system, the
input from an image map (or a form, for that matter) comes in as a bunch of
environment variables.  The "script" itself can be a shell script, a PERL
program, an executable written in C, or whatever you need that can manipulate
environment variables and write text to standard output.


    Christian> Now I was not able to see the code, so I tried myself
    Christian> to create it, I did it like this:

    Christian> <form method=post action=""> <select> <option><a
    Christian> href="..">Chapter 1</a> <option><a href="..">Chapter
    Christian> 2</a> </select> </form>

    Christian> Well, don't try it, it won't work. So now my question
    Christian> is, what kind of code do I have to use. Is it some new
    Christian> feature of HTML 2/3, is it only possible with the
    Christian> commercial version of Netscape, or I am to stupid to
    Christian> find out myself how easy it is (which I really believe)
    Christian> to make a pull-down with links?

    Christian> Who can help me out?

    Christian> I am sorry, but that is NOT all.  I have another
    Christian> problem, namely something of which I think that it is
    Christian> difficult indeed. I need to make a script, I think,
    Christian> that can put some names (taken from the name of some
    Christian> folder/directory) into a standard HTML document.

    Christian> p.e.  <title>hi</title> <h1>hi</h1> <p> <img
    Christian> src=".......1.gif"> <p> img src="......2.gif">

    Christian> etc.  I need to fill in the names where the dots
    Christian> are. TIPS?

One approach would be to explore whether your server knows how to display
directory contents that it builds dynamically for itself.  For example, the
CERN server does this -- it also lets you define a little icon to go next to
each filename, based on it's extension.  When the user clicks on one of the
filenames in the list, it is automatically retreived (i.e. the filenames are
really hypertext links).  This is the way most servers deal with FTP type
requests.

Another way to do what your talking about relies on using a script, as was
discussed earlier in relationship to image maps.  The key concept is that
you can output anything you want from a script, including dynamically created
HTML text!  A very trivial skeleton of this might be a C-Shell script that
works like this:

	echo Content-type: text/html
	echo
	echo '<head>'
	echo '<title>Image List</title>'
	echo '</head>'
	echo '<body>'
	echo 'Here are the images that matched your request:'
	echo '<p>'

	cd /your/directory/goes/here
	set Filenames = `ls *.gif`
	foreach Filename ($Filenames)
	    echo '<img src=\"' $Filename '\">'
	    echo '<p>'
	end

	echo '</body>'

As you can see, the actual text of the page is constructed dynamically,
based on the names of the GIF files in the directory at the time the script
is executed.  You could easily extend this to make the filenames hypertext
links instead of the images themselves, by dynamically constructing an
anchor element (<a href=xxxxx>xxxxx</a>) format, instead of <img src>.

    Christian> Regards,

Good luck!


    Christian> __________________________________________________________
    Christian> Christian Dackus # # # # # # Manager On-line Services

    Christian> Limburg on-line # # # # # # cdackus@knoware.nl
    Christian> __________________________________________________________





----------
Craig R. McClanahan                     EMAIL:  crm@dat.com
DAT Services                            Phone:  503-643-4331
Beaverton, OR, USA                      Fax:    503-526-6442