ရွေးချယ်ခွင့် အညွှန်း Property
ဥပမာ
ရွေးချယ်ထားသော ရွေးစရာ၏ အညွှန်းနှင့် စာသားကို drop-down စာရင်းတွင် ပြပါ-
var x = document.getElementById("mySelect").selectedIndex;
var y = document.getElementById("mySelect").options;
alert("Index: " + y[x].index + " is " + y[x].text);
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
အညွှန်းပိုင်ဆိုင်မှုသည် drop-down list ရှိ ရွေးချယ်မှုတစ်ခု၏ အညွှန်းအနေအထားကို သတ်မှတ်ပေးသည် သို့မဟုတ် ပြန်ပေးသည်။
အညွှန်းကိန်းသည် 0 တွင် စတင်သည်။
Browser ပံ့ပိုးမှု
Property | |||||
---|---|---|---|---|---|
index | Yes | Yes | Yes | Yes | Yes |
အထားအသို
အညွှန်းပိုင်ဆိုင်မှုကို ပြန်ပေးပါ-
optionObject.index
အညွှန်းပိုင်ဆိုင်မှုကို သတ်မှတ်ပါ-
optionObject.index = integer
အိမ်ခြံမြေတန်ဖိုးများ
Value | Description |
---|---|
integer | Specifies the index position of the option within a drop-down list |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | drop-down list အတွင်းရှိ option ၏ အညွှန်းအနေအထားကို ကိုယ်စားပြုသော နံပါတ်။ အညွှန်းကိန်းသည် 0 တွင် စတင်သည်။ |
---|
နောက်ထပ် ဥပမာများ
ဥပမာ
ရွေးစရာအားလုံး၏ စာသားနှင့် အညွှန်းကို drop-down list တွင် ပြပါ-
var x = document.getElementById("mySelect");
var txt = "All options: ";
var i;
for (i = 0; i < x.length; i++) {
txt = txt + "\n" + x.options[i].text + " has index: " + x.options[i].index;
}
❮ ရွေးချယ်စရာ အရာဝတ္ထု