Click to See Complete Forum and Search --> : Help with minor script


staticsystem11
06-11-2003, 04:32 PM
I have a main home web page/form that I have a drop down selector, it only has 2 options. Option 1, the submit will redirect itself to output page 1. On option 2 it will go to another web page for display, output page 2.

I had this script working at one time, but can't figure out why it wont work, I may have lost some piece of it . I am hoping some out there will be able to help me put this nifty piece of code back to working condition?


The main page has text field in it, that upon submit it would choose the outputpage based upon the what choice was made in the drop down selector box. No it is not capable of multiple selections as there are no more than 2 selections available.

However i lost a piece of this some how, and I really need to get this working again.

Heres the piece of code (snippet from web page)


<FORM ACTION="outputpage1.html" name="theForm" id="theForm" onSubmit="formSubmit()">


<SELECT NAME="formAction" size=1 style="" DISPLAY="Select your choice of Display Type">
<OPTION value="outputpage1.html" selected>outputpage1</OPTION><OPTION value="outputpage2.html">outputpage2</OPTION></SELECT>


Can anyone out there help me fix this code?

Thanx a ton in advance

:)

Khalid Ali
06-11-2003, 05:26 PM
Replace this line in your webpage

<SELECT NAME="formAction" size=1 style="" DISPLAY="Select your choice of Display Type">


with this one

<SELECT NAME="formAction" size=1 style="" onchange="Process(this.options[this.selectedIndex].value)" DISPLAY="Select your choice of Display Type">


Then add this function in your javascript section

function Process(val){
if(val=="outputpage1.html"){
document.getElementById("thForm").submit();
}else if(val=="outputpage2.html"){
window.location.href = val;
}
}

staticsystem11
07-01-2003, 08:26 AM
Im sorry Khalid, I tried that code, but it does not do what i want it to do..


So heres what I need:

The javascript code that you gave me auto submits. I do NOT WANT this. I have a picture submit button that this interferes with.

Secondly, as I tried the code, Still have this tag

<FORM NAME="submit keyword" ACTION="display1.cfm" METHOD="POST">

This caused havoc with your code. So all I need is the ability to submit a keyword from the home page, and with the help of the selector, be able to choose 2 different pages to submit to. Thats all that is required from this code. Can you give me
a better example?

I really suck at Javascript.. :P

And thanx again man :)