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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing a variable

Status
Not open for further replies.

GUJUm0deL

Programmer
Jan 16, 2001
3,676
US
Hi, i'm trying to pass a variable using JS, but for some reason my script isn't working, any suggiestions??
Code:
<HTML>
<HEAD>
<script>
function passing(tst) {
  var tst = document.FRM123.subject.value;
  if(document.FRM123.recipient.options[0].selected == true) {
    tst = &quot;Hi mate&quot;;
  }
    if(document.FRM123.recipient.options[1].selected == true) {
    tst = &quot;Hi mate, whas new??&quot;;
  }
    if(document.FRM123.recipient.options[2].selected == true) {
    tst = &quot;Hi mate, howdy...&quot;;
  }
}
</script>	
</HEAD>
<BODY>
<form action=&quot;&quot; method=&quot;POST&quot; enablecab=&quot;Yes&quot; name=&quot;FRM123&quot; onSubmit=&quot;return passing(this.value)&quot;>
<select name=&quot;recipient&quot;>
<option value=&quot;mailto:emailone@aol.com&quot;>Him</option>
<option value=&quot;mailto:emailtwo@hotmail.com&quot;>Her</option>
<option value=&quot;mailto:emailthree@yahoo.com&quot;>They</option>
</select>
<input type=&quot;hidden&quot; name=&quot;subject&quot; value=&quot;tst&quot;>
<input type=&quot;button&quot; name=&quot;submit&quot; value=&quot;submit&quot;>
</form>


</BODY>
</HTML>
I have not failed; I merely found 100,000 different ways of not succeding...
 
Event handler onSubmit works only with real submit.
You have to change the type:
<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;submit&quot;>
They look the same, but their functions differ.
Hope that helps.
 
Hi, thanks for responding, do I still leave in the &quot;onSubmit&quot; event in the form tag?? I have not failed; I merely found 100,000 different ways of not succeding...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top