Reply
Using 2 functions!
Old 09-13-2004, 05:43 AM Using 2 functions!
Experienced Talker

Posts: 37
Im using Javascript and want 2 functions - however with the following code

only one works!!



Code:
 

<script language = "JavaScript">

<!--

function mail() {

var theFields = document.concernform.elements;

var x = theFields["MyTeacher"].value;

if (x == "Other (Support Staff etc)")

theFields["MyEmail"].value = "";

else

if (x == "AAS - Mr A Adams")

theFields["MyEmail"].value = "aadams@wickersley.net";

}

function headmail() {

var theFields = document.concernform.elements;

var y = theFields["MyDepartment"].value;

if (y == "Careers")

theFields["MyHeademail"].value = "Careers";

else

if (y == "Maths")

theFields["MyHeadmail"].value = "Maths";

}

 

//-->

</script>




Any ideas why??

Thanks!
woody22 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 09-14-2004, 01:50 AM
Ultra Talker

Posts: 377
and which one works???
__________________
andrews_john
www.softwareforhosting.com
andrews_john is offline
Reply With Quote
View Public Profile Visit andrews_john's homepage!
 
Old 09-14-2004, 05:30 AM
Skilled Talker

Posts: 72
Unlesss you want one function to run straight into the other after calling the first one....?
In which case you need to call the second one to run (provided that ran the first one..).

Assuming this is the case, why not this?

Code:

<script language = "JavaScript">

<!--

function mail() {

var theFields = document.concernform.elements;

var x = theFields["MyTeacher"].value;

if (x == "Other (Support Staff etc)")
{
theFields["MyEmail"].value = "";
}
else

if (x == "AAS - Mr A Adams")
{
theFields["MyEmail"].value = "aadams@wickersley.net";
}

headmail();
}

function headmail() {

var theFields = document.concernform.elements;

var y = theFields["MyDepartment"].value;

if (y == "Careers")

theFields["MyHeademail"].value = "Careers";

else

if (y == "Maths")

theFields["MyHeadmail"].value = "Maths";

}

 

//-->

</script>

Last edited by BravoGolf : 09-14-2004 at 05:49 AM.
BravoGolf is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Using 2 functions!
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12894 seconds with 12 queries