HTML DOM Pilih bentuk properti
Definisi dan Penggunaan
membentuk kembali properti untuk elemen form yang berisi daftar drop-down referensi.
Properti ini mengembalikan objek bentuk.
tatabahasa
selectObject.form
Dukungan Browser
Semua browser utama mendukung sifat bentuk
contoh
contoh
Formulir menampilkan drop-down daftar id:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi displayResult () {
var x = document.getElementById ( "mySelect") form.id .;
alert (x);
}
</ Script>
</ Kepala>
<Body>
<Form id = "form1">
Pilih buah favorit Anda:
<Pilih id = "mySelect">
<Pilihan> Apel </ option>
<Pilihan> Orange </ option>
<Pilihan> Pineapple </ option>
<Pilihan> Banana </ option>
</ Pilih>
</ Form>
<Tombol type = "button" onclick = "displayResult ()"> display milik bentuk ID </ button>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi displayResult () {
var x = document.getElementById ( "mySelect") form.id .;
alert (x);
}
</ Script>
</ Kepala>
<Body>
<Form id = "form1">
Pilih buah favorit Anda:
<Pilih id = "mySelect">
<Pilihan> Apel </ option>
<Pilihan> Orange </ option>
<Pilihan> Pineapple </ option>
<Pilihan> Banana </ option>
</ Pilih>
</ Form>
<Tombol type = "button" onclick = "displayResult ()"> display milik bentuk ID </ button>
</ Body>
</ Html>
Coba »
Pilih Objek