JavaScript Help Please...!

They have: 6 posts

Joined: Jan 2000

Hi,
OK, this is somewhat hard for me, so any help would be great!

Here's what I need:

I want a drop down box, with two choice (ex: 1 & 2).
Then I have a form.
Now..
if the person chooses #1, so it should send the data to: www.myhost.com/cgi-bin/form1.pl

Else..
is he chooses #2, it should send the data to www.myhost.com/cgi-bin/form2.pl

Any ideas?

P.S. It doesn't have to be a drop down box. Anyhthing that works is great!

Thanks!

They have: 231 posts

Joined: Feb 2000

I would use two separate forms in this case. Collect data from one form, then run a script to determine which form to submit. You can send the data you collect to a hiiden input field.

code:

function submitForm() {
   if (document.forms["form1"].elements["selectOptions"].options[0].selected == true) {
      // send data to hidden input form1
      document.forms["form1"].submit();
      }
   else {
      // send data to hidden input form2
      document.forms["form2"].submit();
      }
   }
[/code]

code:
<form
name="form1"
action="www.myhost.com/cgi-bin/form1.pl">
<select name="selectOptions">
<option>1
<option>2
</select>
<input type="button" onClick="javascript:submitForm()" value="Submit">
<input type="hidden" name="input1">
</form>

<form
name="form2"
action="www.myhost.com/cgi-bin/form2.pl">
<input type="hidden" name="input2">
</form>[/code] 

:: Lloyd Hassell :: http://www14.brinkster.com/lloydh ::

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.