mr_ego
10-21-2003, 07:43 AM
When manipulating a form element, i use:
document.formname.elements["item_name"]. ... etc.
but that only works in Mozilla and NS.
This is because these browsers dont like _'s and require the form element to be represented in a readable string.
For Internet Explorer do i just do:
document.formname.item_name. ... ?
or is there a better way?
Roelf
10-21-2003, 07:46 AM
most of the time i use:
document.forms["formname"].elements["elementname"]
works in ie and moz afaik
glenngv
10-21-2003, 10:28 AM
document.formname.elements["item_name"] works in all browsers. I have had no problem with IE using that method.
mr_ego
10-21-2003, 11:46 AM
document.forms["userdefform"].elements["fieldname"].options[0] = new Option("text", "value");
IE: FAILED
NS: SUCCESS
document.userdefform.elements["fieldname"].options[0] = new Option("text", "value");
IE: FAILED
NS: SUCCESS
anything else?
glenngv
10-21-2003, 12:02 PM
I've created a simple page with your code in it and it works for me. Im using IE5.5. Can I see your whole code?
Roelf
10-21-2003, 12:05 PM
<html>
<head>
<title></title>
<script language="javascript">
function addelement () {
document.forms["formname"].elements["elementname"].options[0] = new Option("", "");
document.forms["formname"].elements["elementname"].options[1] = new Option("text", "value");
}
function showvalue (objSelect) {
alert (objSelect.options[objSelect.options.selectedIndex].value);
}
</script>
</head>
<body>
<form name="formname">
<select name="elementname" onchange="showvalue(this)">
</select>
<input type="button" onClick="addelement();" value="add">
</form>
</body>
</html>
works in ie