Click to See Complete Forum and Search --> : two js files from one page
webbotto
04-25-2003, 07:39 AM
My page at http://frontier.dreamhost.com/askbutt3.htm
has two buttons, each calling a different .js file. But only one button works at a time...and each button is calling the same file.
The two .js files are identical except for a different message in each one.
I am a newbie.
AdamGundry
04-25-2003, 07:48 AM
Both scripts have a function of the same name, so the second occurence of the function overwrites the first. Simply give the functions different names, and this should work.
Adam
webbotto
04-25-2003, 06:43 PM
Thanks, but what would be the "function name" in the aforementioned script (reproduced below)? How would I change it to differ from my second script (identical to the one below except for the src value) ?
<script language="JavaScript" src="01.js">
</script>
<FORM NAME= "msgform1" ACTION="src='01.js'">
<input type="button" value="Click Here One" onClick="DisplayMsg()">
</FORM>
havik
04-25-2003, 08:13 PM
It appears as though both js files have this function (I didn't look directly but saw them on your page):
DisplayMsg()
Change the name of this function in one of the scripts to
DisplayMsg2()
and don't forget to mimic that change in your askbutt3.htm file as well.
havik
webbotto
04-26-2003, 12:46 AM
Hmmm...I did that on my page http://frontier.dreamhost.com/askbutt6.htm, changing to DisplayMsg2() on that page and in the second .js file. But the second message still overrides the first, although now the second button doesn't do anything.
AdamGundry
04-26-2003, 11:32 AM
I had a more detailed look at the two scripts - it seems you have used the same script twice, so all the variable names are the same. You need to either use one copy of the script, passing parameters to the functions so they know which button to change, or rename all the variables in the second script to stop the conflicts.
Adam