cancel
Showing results for 
Search instead for 
Did you mean: 

Dropdown List selection with javascript

Former Member
0 Kudos

hi all...

I just want to know how to select the first item of a dropdown list as its default value instead of the value "ALL" in web application designer using javascript.

If someone can help me with this i will be very grateful.

Thanks and regards.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

use selectedIndex to set by index

use value to set a value

<HTML>
<HEAD>
<TITLE> Select </TITLE>

<script>
function sel(index) {
	document.getElementById("selectionBox").selectedIndex=index;
}
function selVal(index) {
	document.getElementById("selectionBox").value=index;
}
</script>
</HEAD>
<BODY onload1="sel(1)" onload="selVal('v2')">
<select id="selectionBox">
	<option value="v0" >Zero</option>
	<option value="v1" >One</option>
	<option value="v2" >Two</option>
</select>
</BODY>
</HTML>

Answers (0)