User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 375,172 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,090 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1379 | Replies: 4 | Solved
Reply
Join Date: Jun 2006
Posts: 3
Reputation: nicekitty is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
nicekitty nicekitty is offline Offline
Newbie Poster

Question 2 duplicate javascriptsscripts on 1 webpage?

  #1  
Aug 20th, 2006
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 2:44 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2004
Location: Hemet, CA
Posts: 427
Reputation: FC Jamison is on a distinguished road 
Rep Power: 5
Solved Threads: 17
Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Solution Re: 2 duplicate javascriptsscripts on 1 webpage?

  #2  
Aug 20th, 2006
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 6:14 pm.
Reply With Quote  
Join Date: Jun 2006
Posts: 3
Reputation: nicekitty is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
nicekitty nicekitty is offline Offline
Newbie Poster

Re: 2 duplicate javascriptsscripts on 1 webpage?

  #3  
Aug 20th, 2006
Ah!
Reply With Quote  
Join Date: Jun 2006
Posts: 3
Reputation: nicekitty is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
nicekitty nicekitty is offline Offline
Newbie Poster

Re: 2 duplicate javascriptsscripts on 1 webpage?

  #4  
Aug 20th, 2006
Ah! Thanks so much. That makes so much sense. So simple, really.

Sure appreciate the help!

cheers ~
Denise
Reply With Quote  
Join Date: Jun 2004
Location: Hemet, CA
Posts: 427
Reputation: FC Jamison is on a distinguished road 
Rep Power: 5
Solved Threads: 17
Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Re: 2 duplicate javascriptsscripts on 1 webpage?

  #5  
Aug 20th, 2006
No Problem
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 12:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC