을이 마크 업의 경우 :이 코드는
<select id="text3">
<option>Original Item</option>
</select>
: 자바 스크립트를 사용하는 경우
이
window.onload = function() {
var test= document.getElementById('text3');
// this will add 3 option tags as children of the select:
test.options[test.options.length] = new Option('TextValue','ValueValue');
test.options[test.options.length] = new Option('TextValue2','ValueValue2');
test.options[test.options.length] = new Option('TextValue3','ValueValue3');
// this will select the 2nd option
test.options.selectedIndex=1;
}
, 다음 변환 될 것입니다 입력란 :
<select id="text3">
<option>Original Item</option>
<option value="ValueValue">TextValue</option>
<option value="ValueValue2">TextValue2</option>
<option value="ValueValue3">TextValue3</option>
</select>
라이브러리를 사용하면 훨씬 쉽게 달성 할 수 있지만 시작하면됩니다.
마찬가지로 test.options.selectedIndex=1;
을 사용하면 어느 것을 선택해야하는지 코드를 설정할 수 있습니다. 그것들은 인덱스가 0이므로 첫 번째 것은 0이고 두 번째는 1, 세번째는 2 등입니다.
Dynamic? sth like ..i는 모든 selectonemenu를 반복하고 기본값으로 설정합니다. .. JSF를 사용하고 있습니다. – user234194