<!DOCTYPE html>
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Odor+Mean+Chey' rel='stylesheet'>
</head>
<body style="font:14px/1.5 'Odor Mean Chey'">
ចុចជ្រើសរើសយកផ្លែឈើដែលអ្នកពេញចិត្ត។
<script>
function myFunction(){
var selectObject = document.getElementById("mySelect");
var element = document.getElementById("info");
element.innerHTML = "អ្នកបានជ្រើសរើសយក: " + selectObject.value;
}
</script>
</body>
</html>
ចុចជ្រើសរើសយកផ្លែឈើដែលអ្នកពេញចិត្ត។
នៅលើបន្ទាត់លេខ 23 គឺជាការយកវិធី getElementById() នៅក្នុង DOM មកប្រើដើម្បីភ្ជាប់ទំនាក់ទំនងទៅនឹងធាតុ select ដែលមានអត្តសញ្ញាណជា mySelect ។
នៅលើបន្ទាត់លេខ 24 គឺជាការយកវិធី getElementById() នៅក្នុង DOM មកប្រើដើម្បីភ្ជាប់ទំនាក់ទំនងទៅនឹងធាតុ HTML ដែលមានអត្តសញ្ញាណជា info ។
នៅលើបន្ទាត់លេខ 25 ការសរសេរថា selectObject.value គឺជាការចំលងយកទិន្នន័យដែលជាជំរើសរបស់អ្នកប្រើប្រាស់នៅក្នុងធាតុ select មកបញ្ចូលទៅក្នុងធាតុ HTML ដែលមានអត្តសញ្ញាណជា info ។
Select Object Properties & Methods
| Property/Method | Description |
|---|---|
| autofocus | Sets or returns whether a drop-down list should automatically get focus when the page loads |
| disabled | Sets or returns whether the drop-down list is disabled, or not |
| form | Returns a reference to the form that contains the drop-down list |
| length | Returns the number of <option> elements in a drop-down list |
| multiple | Sets or returns whether more than one option can be selected from the drop-down list |
| name | Sets or returns the value of the name attribute of a drop-down list |
| selectedIndex | Sets or returns the index of the selected option in a drop-down list |
| size | Sets or returns the value of the size of a drop-down list |
| type | Returns which type of form element a drop-down list is |
| value | Sets or returns the value of the selected option in a drop-down list |
| add() | Adds an option to a drop-down list |
| remove() | Removes an option from a drop-down list |














