[Javascript] how can change select's options dynamic
piaohw
piaohw at neusoft.com
Mon Oct 14 00:54:52 CDT 2002
Thanks!
But you misunderstanded the problem I meet.
The originally meaning I refered is how to change the options's value nor to change which one being selected.I find the solutions of the problem.
targetobj is the select object I want to change its options , the refereddata is an array to store the values I want to change to select object's options's text.
for (i = 0; i < refereddata.length; i++) {
var newOption = document.createElement("OPTION");
newOption.text="refereddata[i]";
newOption.value="i";
targetobj.options[i] = new Option(newOption.text,newOption.value);
}
targetobj.length = i;
----- Original Message -----
From: Dan Costea
To: javascript at LaTech.edu
Sent: Monday, October 14, 2002 2:12 PM
Subject: Re: [Javascript] how can change select's options dynamic
here is an example:
<html>
<head>
<script type="text/javascript">
function testing ()
{
myCombo.selectedIndex = 4;
}
</script>
</head>
<body>
<center>
<button onclick="testing ();">just testing</button>
<select id="myCombo">
<option>zero</option>
<option selected>one</option>
<option>two</option>
<option>three</option>
<option>four</option>
<option>five</option>
</select>
</center>
</body>
</html>
If you want more about HTML "select" object, look on the documentation (this is for IE):
http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/select.asp
----- Original Message -----
From: piaohw
To: javascript at LaTech.edu
Sent: Monday, October 14, 2002 2:48 AM
Subject: [Javascript] how can change select's options dynamic
hi:
I want change select's options dynamic without refresh page,but I don't know how to.If the function like this can realize,if you know ,please tell me .Thanks!
Steven Piao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20021014/58770c17/attachment.htm>
More information about the Javascript
mailing list