|
-
Jun 26th, 2000, 10:03 PM
#1
Thread Starter
Lively Member
How do I add items to a combobox in a HTML doc with JavaScript?
the Combobox looks like this:
<SELECT id="select2" name="name2" style="HEIGHT: 22px; WIDTH: 142px">
<OPTION selected value="n/a"></OPTION>
</SELECT></P>
and here's the JavaScript function that I've got so far.
Depending on what item in another combobox the user clicked on, different items go into combobox2
Code:
function select1_onclick(val)
{
select2.clearAttributes;
switch (val)
{
case "n/a": select2.clearAttributes; break;
case "hs":
//add items to select2
break;
case "hm":
//add items to select2
break;
default:
break;
}
}
Any suggestions?
Thanks in advance, Nina
-
Jun 27th, 2000, 01:50 AM
#2
Frenzied Member
this code adds items to a <select> box using Javascript
Is this any use to you?
Code:
<BODY><HEAD>
<script Language="JavaScript">
var i;
function AddItem(){
i++;
var oOption = document.createElement("OPTION");
oOption.text="Apples";
oOption.value=i;
document.frm1.select1.add(oOption);
}
</script>
</head>
<form name="frm1">
<SELECT id=select1 name=select1 size=2 style="HEIGHT: 134px; WIDTH: 258px">
</SELECT>
</form>
<input type="button" onclick="AddItem()" value="Click">
</BODY>
</HTML>
-
Jun 27th, 2000, 01:43 PM
#3
Thread Starter
Lively Member
Thanks, Mark
That's just about what I need.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|