[UPHPU] Javascript question
thebigdog
bigdog at venticon.com
Thu Jul 9 12:46:14 MDT 2009
> If I have a select with several options, one of which is "selected", how do
> I de-select the original selected option and set a different option as
> selected using javascript? Is it possible? I have successfully set the
> values of inputs before but never this.
you need to use the select and option objects with javascript and set the default.
here is an example:
var myselect=document.getElementById("sample")
for (var i=0; i<myselect.options.length; i++){
if (myselect.options[i].selected==true){
alert("Selected Option's index: "+i)
break
}
}
myselect.selectedIndex = 3; // sets the selected index for the select object
--
thebigdog
More information about the UPHPU
mailing list