<!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> <title> new document </title> <script type="text/javascript"> <!-- function setSelect(_text, _value) { var obj = document.getElementById('s1'); var option = document.createElement("OPTION");
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<script type="text/javascript">
<!--
function setSelect(_text, _value)
{
var obj = document.getElementById('s1');
var option = document.createElement("OPTION");
for(ix=0; ix< test.s1.options.length; ix++)
{
option = obj.options[ix];
//option.text = obj.options[ix].text;
//alert(option.value);
//alert(option.text);
if(option.value == _value && option.text == _text)
{
obj.selectedIndex = ix;
break;
}
}
}
//-->
</script>
</head> <body>
<form method="post" id="test" action="">
<select id="s1">
<option selected="selected" value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
<option value="3">D</option>
</select>
<script>setSelect('C', '3');</script>
</form>
</body>
</html>