944,129 Members | Top Members by Rank

Ad:
Aug 20th, 2006
0

2 duplicate javascriptsscripts on 1 webpage?

Expand Post »
Hi everyone,

I let a friend use a directory on my website for his art e-zine. He emailed me this morning because he's having trouble getting 2 forms with the same javascript to work on the same page.

I really don't know anything about javascript, though (neither does he), and we can't quite figure out how to make it work. He just copied/pasted the script from somewhere.

He has 2 drop-down lists on the page. One is a menu of paintings by a particular artist; the second is a menu of drawings by the same artist.

There is a script for each of the 2 forms, that makes it so when a menu item is selected, you are taken to that page in question immediately, without having to hit a "go" button or something of that nature.

It works fine when only one form is on the page, but when the second form is added, neither work.

If anyone can enlighten us, I'd be most appreciative.

The URL is http://www.emptymirrorbooks.com/thirdpage/pullMDSx.html

Thanks so much!!
cheers ~
Denise
Last edited by nicekitty; Aug 20th, 2006 at 3:44 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nicekitty is offline Offline
3 posts
since Jun 2006
Aug 20th, 2006
0

Re: 2 duplicate javascriptsscripts on 1 webpage?

Your problem is that you have two functions with the same name calling two forms with the same.


For the first form/script:

[html]
<script language="JavaScript" type="text/javascript">
<!-- Begin
function formHandler(form){
var URL = document.form.site.options[document.form.site.selectedIndex].value;
window.location.href = URL;
}
// End -->
</script>
<center><p></p>
<form name="form" action="get">
<select name="site" size=1 onChange="javascript:formHandler()">
[/html]

For the second form/scrpt:

[html]
<script language="JavaScript" type="text/javascript">
<!-- Begin
function formHandler2(form){
var URL = document.form2.site2.options[document.form2.site2.selectedIndex].value;
window.location.href = URL;
}
// End -->
</script>
<center><p></p>
<form name="form2" action="get">
<select name="site2" size=1 onChange="javascript:formHandler2()">
[/html]

note changes to the function names, object names , form names, and select names.
Last edited by FC Jamison; Aug 20th, 2006 at 7:14 pm.
Team Colleague
Reputation Points: 92
Solved Threads: 21
Posting Pro in Training
FC Jamison is offline Offline
436 posts
since Jun 2004
Aug 20th, 2006
0

Re: 2 duplicate javascriptsscripts on 1 webpage?

Ah!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nicekitty is offline Offline
3 posts
since Jun 2006
Aug 20th, 2006
0

Re: 2 duplicate javascriptsscripts on 1 webpage?

Ah! Thanks so much. That makes so much sense. So simple, really.

Sure appreciate the help!

cheers ~
Denise
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nicekitty is offline Offline
3 posts
since Jun 2006
Aug 20th, 2006
0

Re: 2 duplicate javascriptsscripts on 1 webpage?

No Problem
Team Colleague
Reputation Points: 92
Solved Threads: 21
Posting Pro in Training
FC Jamison is offline Offline
436 posts
since Jun 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Photoshop - javascript slice : error : copy command not available??
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Random sound/midifile with a button





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC