Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onChange event

Status
Not open for further replies.

JazzLeg

Programmer
Aug 22, 2002
63
GB
Hello,

What I need to do is: when a drop down box is changed, I want to send its value and that of another form element to a function. This then posts another page with the variables.

Anyways this works fine in explorer but returns a null for value1 (but returns value2) when I use netscape.

Here is my code:

Code:
<select name=&quot;varA&quot; onchange=&quot;hot_fault(form1.value1.value,form1.value2.value);&quot;> 
		
<option value=&quot;&quot;>Select</option>
<option value=&quot;1&quot;>1</option>  
<option value=&quot;2&quot;>2</option>
<option value=&quot;3&quot;>3</option> 

</select>

And this function in the head:

Code:
<script>
function hot_fault(value1,value2) {	
		window.location = &quot;contact.asp?varA=&quot; + value1 + &quot;&varB=&quot; + value2 + &quot;&opt=1&quot;;	
}
</script>

Can anyone help?
 
netscape nees a document. for object referencing. also a return statement. _________________________________________________________
for the best results to your questions: FAQ333-2924
[sub]01001111 01101110 01110000 01101110 01110100[/sub]
onpnt2.gif
[sup] [/sub]
 
Sorry to be dumb but where abouts would I put document. and the return statement.

Many thanks
 
when I re-read your question I get that you want to send two values. the selection and the other form field? right?

you said this works in IE but I'm trying to figure out how it could when you don't have reference to the select field in the event.
<select name=&quot;varA&quot; onchange=&quot;hot_fault(here-->form1.value1.value,form1.value2.value);&quot;>
there's no reference to the varA name of the element.

when you reference a select you use the selectedIndex clause to get the value selected.
so:
document.form1.varA.options[document.form1.varA.selectedIndex].value
or the shortcut version of this.selecedIndex

the other field should be stated as documment.form1.value1.value

as for return. you need to use the return mainly in a form in Netscape (not sure if 7 changed this) to either stop processing and return a boolean value for comparison or return a value from conditioning.

simply add
<select name=&quot;varA&quot; onchange=&quot;return hot_fault(this.selecedIndex,document.form1.value2.value);&quot;>

and validate to return false or true

That's not what your doing so it is not needed. sorry for the misdirection there. _________________________________________________________
for the best results to your questions: FAQ333-2924
[sub]01001111 01101110 01110000 01101110 01110100[/sub]
onpnt2.gif
[sup] [/sub]
 
The value1, value2 bit was a typo, but i had no idea about using the selectedIndex but now I do and it works in Netscape and IE!!!

Thanks very much onpnt.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top