JScriptNewbie
03-01-2003, 11:55 PM
Help! I made a "select-and-go" menu. I would like to have an alert pop up when a choice has been selected, but I don't know how to make that happen. :confused: Any suggestions?
-JScriptNewbie
-JScriptNewbie
|
Click to See Complete Forum and Search --> : Select-and-Go menu JScriptNewbie 03-01-2003, 11:55 PM Help! I made a "select-and-go" menu. I would like to have an alert pop up when a choice has been selected, but I don't know how to make that happen. :confused: Any suggestions? -JScriptNewbie pyro 03-02-2003, 12:08 AM You could do it like this... <html> <head> <script type="text/javascript"> function pulldown(form) { var alerts = form.menu.options.value; if (alerts == 1) { alert("Alert One"); } if (alerts == 2) { alert ("Alert Two"); } } </script> </head> <body> <form name=form> <select name=menu SIZE=1 onChange="pulldown(this.form)"> <option value="#">Go to....</option> <option value="1">Alert One</option> <option value="2">Alert Two</option> </select> </form> </body> </html> JScriptNewbie 03-02-2003, 09:06 PM Thanks for the suggestion! I'll try it and see what happens. JScriptNewbie 03-02-2003, 10:21 PM OK. I had to use pyro's suggestion because it worked better (no offense or anything), and now I have another problem. I got the alerts to work, but I want the alerts to do something. Sorry, that was vague. Ummm....when the "OK" button is pressed on the alert, I want more text to appear on my page, but only if the right choice is selected. If the wrong choice is selected, when the person hits the "OK" button, I want them to be located to another page. Is this possible??? Or am I just being confusing? :( JScriptNewbie 03-02-2003, 11:23 PM Actually, I don't think I meant any of those things. I think what I meant was that the example that pyro gave was exactly what I wanted, while yours worked in a more roundabout way that didn't do exactly what I wanted it to. I'm new at this JavaScript thing, so I'm not used to changing things to get them to do what I want them to, especially if they are more complex. Does that make sense? :( pyro 03-03-2003, 07:04 AM Dave Clark is correct. You'd be better off using this code: <html> <head> <script type="text/javascript"> function pulldown(form) { var alerts = form.options[form.selectedIndex].value; if (alerts == 1) { alert("Alert One"); } if (alerts == 2) { alert ("Alert Two"); } } </script> </head> <body> <form name=form> <select name=menu SIZE=1 onChange="pulldown(this)"> <option value="#">Go to....</option> <option value="1">Alert One</option> <option value="2">Alert Two</option> </select> </form> </body> </html>It's pretty much the same code, with two simple changes.. pyro 03-03-2003, 07:26 AM ARG...I think I need to go back to bed... :D Thanks Dave, edited to fix... JScriptNewbie 03-03-2003, 07:56 PM Guys, I love the enthusiasm, but the first one worked just fine! Really! Everything is just peachy. ;) Besides, for now, I only need it to work in IE. I can worry about cross-browsing later. Now I did have another question in hear, but I guess I'll have to post another thread to have it get some attention. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |