Javascript download menu problems
|
Original Message
|
Name: zach williams
Date: February 9, 2005 at 12:18:07 Pacific
Subject: Javascript download menu problemsOS: xp proCPU/Ram: 3.4g 512ddr2 |
Comment: Hi, I am having problems getting two javascript download menu's to work. If put in another menu neither will work. I dont know what to do. Do i need two jascripts or what? I want the two download menus since i have two distinct categories. You can look that the page to see what i am trying to do. Notice that i just took down some stuff off the page and just put up a notice, but the two forms are there. The code isnt correct and all im sure. Im really lost of ideas and i have searched and searched for how to get two menus. I have also tried naming teh form tag to but nothing works. If someone could tell me how it would be greatly appreaciated. Thanks
Report Offensive Message For Removal
|
|
Response Number 2
|
Name: Michael J (by mjdamato)
Date: February 9, 2005 at 14:01:47 Pacific
Subject: Javascript download menu problems |
Reply: (edit)The first thing that i notice is that you have two forms and you gave them both the same name. Can't do that. They need to have unique names. First, give them unique names such as form1 and form2 (or something that makes sense to you). Then change the Go button onclick events to be this: onclick="javascript:formHandler(this.form)" Lastly change the formHandler function to this: function formHandler(form){ var URL = form.site.options{form.site.selectedIndex].value; window.location.href = URL; } Michael J
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Michael J (by mjdamato)
Date: February 9, 2005 at 14:04:23 Pacific
Subject: Javascript download menu problems |
Reply: (edit)Sorry, messed up one of the characters in the function. Should be this: function formHandler(form){ var URL = form.site.options[form.site.selectedIndex].value; window.location.href = URL; } Michael J
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: zach williams
Date: February 9, 2005 at 16:18:41 Pacific
Subject: Javascript download menu problems |
Reply: (edit)Ok now on the form thing do i need seperate scripts kinda like this. First one: function formHandler(form2){ var URL = form.site.options[form2.site.selectedIndex].value; window.location.href = URL; } onclick="javascript:formHandler(this.form2)" Second form: function formHandler(form1){ var URL = form1.site.options[form1.site.selectedIndex].value; window.location.href = URL; } onclick="javascript:formHandler(this.form1)" Do i even need to put the form name where it says form or what? like i did form1 form2 Because i have tried naming them different forms then testing them out on preview since i already have the files uploaded. By the way i am using dreamweaver mx if that matters any. Thanks
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: Michael J (by mjdamato)
Date: February 9, 2005 at 17:43:45 Pacific
Subject: Javascript download menu problems |
Reply: (edit)Just follow exactly what i wrote and it will work. Give the forms two differnt names (it doesn't matter what). Then each button needs to use the onClick event: onclick="javascript:formHandler(this.form)" You do not need to rename anything - they will both be the same. "this.form" is a pointer to the current form - that's why you can name the forms anything you want. You need just one function as I wrote above: function formHandler(form){ var URL = form.site.options[form.site.selectedIndex].value; window.location.href = URL; } The onClick event handlers are passing the form as a variable to the function as I described earlier. The first line of the function (function formHandler(form){ ) assigns the form that is passed to the function as the variable 'form'. As for DreamWeaver I cannot give you any advice. I write all of my own code. Never used any WYSIWYG programs. Go ahead and give it a try. If you run into any problems, post back here and click the Alert Me link on one of my posts. Good luck! Michael J
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: