Skip to main content

Posts

Showing posts from February, 2011

Selected value/ selected index from dropbox javascript

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script> function haha() { //var e = document.getElementById("select"); var strUser = document.getElementById("select").options[document.getElementById("select").selectedIndex].text; // If you would like to select value then use "value" in place of  "text" alert(strUser); } </script> </head> <body> <select name="select" id="select" onchange="haha();"> <option value="1">a1</option> <option value="2">a2</option> <option value="3">a3</option...