Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Thursday, July 31, 2008

Javascript: Confirmation Alert

if ( confirm("are you sure?") )
alert( 'you chose yes' );
else
alert("you chose no");

Thursday, April 24, 2008

JavaScript: Drop Down Menus

In case you ever wondered how to do this here is an A List Apart article on how to do it very simply.

http://www.alistapart.com/articles/dropdowns

Please stop downloading really bad implementations and trying to hack them together. Just read this article (yes all of it) and then do it yourself. I promise you its not that hard.

*Takes your hand* Don't be scared. You'll be better for it I promise.

Monday, April 21, 2008

Javascript: Get a Value from a Drop Down Menu

To get the value:
document.getElementById( 'dropdownmenu_id' ).options[ document.getElementById('dropdownmenu_id').selectedIndex ].value


To get the Option Name:
document.getElementById('dropdownmenu_id').options[ document.getElementById('dropdownmenu_id').selectedIndex ].text


if you use prototype.js framework then you can replace the
references to 'document.getElementById' with a $