Re: [htdig] Is This Correct ??


Subject: Re: [htdig] Is This Correct ??
From: Brett Baugh (brett.baugh@cyberplex.com)
Date: Fri Mar 17 2000 - 09:10:44 PST


"Simon Hyde - Webyte.co.uk" wrote:

> I am not sure if it is using the second option box in the query, is the
> above correct or am I doing something wrong here ??

The above isn't correct. :) You have to concatenate the selected items from
the two select lists into one single form variable called "words"... meaning
neither of the list boxes can be called "words" and just about the only way
it'll work is if you have a javascript thingy that takes the values of each one
and...... it's harder to explain than to just show you:

For the <form> (which MUST have a name!) you have:
---------------------------------
<form name=ThisForm method=blah action=blah onSubmit="addWords()">
<select name=select1>
   <option value="">Select Something</option>
   <option value="whatever1">Whatever 1</option>
   <option value="whatever2">Whatever 2</option>
   <option value="whatever3">Whatever 3</option>
   ....
</select>
<select name=select2>
   <option value="">Select Something</option>
   <option value="whatever1">Whatever 1</option>
   <option value="whatever2">Whatever 2</option>
   <option value="whatever3">Whatever 3</option>
   ....
</select>
<input type=hidden name="words" value="">
<input type=submit value=" Go! ">
</form>
---------------------------------
...or something. (Don't forget to put in the required hidden fields too, for
"config" and "method", etc!) And yes, those first <option> fields with the
blank values should be there so it'll still work if they only pick one. Now,
in the <head> of the document, put something like:
---------------------------------
<script language="Javascript">
function addWords() {
    var out="";
    var e=document.ThisForm;
    out += e.select1.options[e.select1.selectedIndex].value;
    out += " ";
    out += e.select2.options[e.select2.selectedIndex].value;
    document.ThisForm.words.value=out;
    document.ThisForm.submit();
}
</script>
---------------------------------
Now. When you submit this form, the "addWords" function gets called, the
values from the two select boxes get added together with a space between them,
that value is assigned to the "words" variable in the hidden field, and the
form is submitted. Voila. This method could be used for any number of select
boxes, of course; just add more "out +=" lines for each box.......

_________________________
Brett Baugh
System Administrator/Unix Programmer
Cyberplex Interactive Media
http://austin.cyberplex.com
512.795.3050
"Obviously, the Microsoft spin doctors are trying to associate the word
'innovation' with Windows 98 in the minds of the public. This is cute, since
there is very little innovation in Windows 98. Everything in the OS is either a
geegaw, a bug fix, or some new support, such as that for USB."
-- John Dvorak, PC Magazine



This archive was generated by hypermail 2b28 : Fri Mar 17 2000 - 08:08:18 PST