B
Brian D
I am trying to use AddChild in IE. The script is on a document loaded
into an iframe. This works in Firefox but not IE. I receive "Invalid
argument" on "objSelect.appendChild(optGroup)"
What gives?!
Thank
Brian
form.html
<html>
<head>
</head>
<body>
<form name="form1">
<table bgcolor="#cccccc" width="100%" cellpadding="3" cellspacing="1"
border="0">
<tr bgcolor="#ffffff">
<td width="150" align="left" valign="top"><b>Item Cross
Reference:</b><br>(if any)</td>
<td align="left" valign="top">
<select name="itemcross" id="itemcross" size="5" STYLE="width: 400px"
multiple>
<option value="">Select One...</option>
</select>
</td>
</tr>
</table>
</form>
<iframe src="optgroup.html" name="ifrm" id="ifrm" width="100%"
height="200" scrolling="yes">Sorry, your browser doesn't support
iframes.</iframe>
</body>
</html>
optgroup.html
<html>
<head>
<script language="JavaScript" type="text/javascript">
function create_optgroup(){
objSelect=window.parent.document.getElementById('itemcross')
optGroup = document.createElement('optgroup')
optGroup.label = "New Group"
objOption=document.createElement("option")
objOption.innerHTML = "Sample1"
objOption.value = "sample1"
objSelect.appendChild(optGroup)
optGroup.appendChild(objOption)
}
</script>
</head>
<body>
<input type="button" value="test" onclick="create_optgroup();">
</form>
</body>
</html>
into an iframe. This works in Firefox but not IE. I receive "Invalid
argument" on "objSelect.appendChild(optGroup)"
What gives?!
Thank
Brian
form.html
<html>
<head>
</head>
<body>
<form name="form1">
<table bgcolor="#cccccc" width="100%" cellpadding="3" cellspacing="1"
border="0">
<tr bgcolor="#ffffff">
<td width="150" align="left" valign="top"><b>Item Cross
Reference:</b><br>(if any)</td>
<td align="left" valign="top">
<select name="itemcross" id="itemcross" size="5" STYLE="width: 400px"
multiple>
<option value="">Select One...</option>
</select>
</td>
</tr>
</table>
</form>
<iframe src="optgroup.html" name="ifrm" id="ifrm" width="100%"
height="200" scrolling="yes">Sorry, your browser doesn't support
iframes.</iframe>
</body>
</html>
optgroup.html
<html>
<head>
<script language="JavaScript" type="text/javascript">
function create_optgroup(){
objSelect=window.parent.document.getElementById('itemcross')
optGroup = document.createElement('optgroup')
optGroup.label = "New Group"
objOption=document.createElement("option")
objOption.innerHTML = "Sample1"
objOption.value = "sample1"
objSelect.appendChild(optGroup)
optGroup.appendChild(objOption)
}
</script>
</head>
<body>
<input type="button" value="test" onclick="create_optgroup();">
</form>
</body>
</html>