<select name="hej" disabled>
...
</select>
eller med skript:
document.forms[0].hej.disabled = true;
6 svar · 269 visningar · startad av clown
Hej
Jag undrar hur man skulle göra om man har en select lista som man ibland INTE skall kunna välja något från.
Så hur 'låsre' man en select lista så att det inte går att välja från den??
<select name="hej" disabled>
...
</select>
eller med skript:
document.forms[0].hej.disabled = true;
Ahhaa....
Men funkar detta i både NS och IE ??
För i netscapes javascript ref fanns inte denna med!
disabled, är så vitt jag vet, ett ie-only attribut.
men det är väl inte så svårt att testa om det funkar i netscape
Det är en del av DOM Level1 HTML:
Object HTMLSelectElement
HTMLSelectElement has the all the properties and methods of HTMLElement as well as the properties and methods defined below.
The HTMLSelectElement object has the following properties:
type
This property is of type String.
selectedIndex
This property is of type long.
value
This property is of type String.
length
This property is of type long.
form
This property is of type HTMLFormElement.
options
This property is of type HTMLCollection.
disabled
This property is of type boolean.
multiple
This property is of type boolean.
name
This property is of type String.
size
This property is of type long.
tabIndex
This property is of type long.
The HTMLSelectElement object has the following methods:
add(element, before)
This method returns a void. The element parameter is of type HTMLElement. The before parameter is of type HTMLElement.
remove(index)
This method returns a void. The index parameter is of type long.
blur()
This method returns a void.
focus()
This method returns a void.
Saxat från:
http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
Snyggt R.G.B!
Dessvärre så är det inte säkert att IE och NN stöder allt det som står i DOM-specifikationen. Men disabled fungerar bra både i IE och NN.
Jag tackar och bugar för den eminenta hjälp man har fått och kan få av dessa underbara, upplysta personer som hangs around på detta forum
/Jonas