 |
 |
innerText is only an extension?
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jun 2004
Status:
Offline
|
|
I've seen some mention that this property is an MS-IE extension. And I've seen that innerHTML can be a suitable substitution for Macs(which it appears to be in this case). Have confirmed its not the contents of the array elements causing trouble (at least as far as what's expected in the array).
Both innerText and innerHTML fail (the browser stops responding and must be closed).
Statement 3 below is fine -- its the first iteration of statement 8 that fails. And yup, this code is fine in a MS environment. The only Mac environment attempted is OSX.
Can anyone shine a light? Thanks to all and any. B.
...
1: oOption = document.createElement("OPTION");
2: document.forms(0).drpServiceID.options.add(oOption );
3: oOption.innerText = "-None-"
4: oOption.value = "";
5: for (x=0;x<arr1Services.length;x++)
6: { oOption = document.createElement("OPTION");
7: document.forms(0).drpServiceID.options.add(oOption );
8: oOption.innerText = Trim(arr1Services[x]);
9: oOption.value = Trim(arr1Services[x]);
10: }
...
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Nov 1999
Status:
Offline
|
|
innerText and innerHTML are actually both extensions to the DOM.
|
|
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status:
Offline
|
|
I think option.text = "whatever"; will work, but I'm not sure (haven't tried to do this in ages).
If not, creating a textNode and appending that (the DOM way) would work.
(Last edited by Black Book; Jun 14, 2004 at 09:18 AM.
)
|
|
Just who are Britain? What do they? Who is them? And why?
Formerly Black Book
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
I think this might be what you are looking for... next time ask a better question (in this case: I am trying to programatically add an option using JavaScript.... then start asking specific questions like about InnerHTML...)
Code:
<html>
<head>
<title>Empty Document</title>
<script>
function doIt () {
myOptions = document.forms[0].elements[0].options;
thisObject = new Option('bob');
myOptions[myOptions.length] = thisObject;
}
</script>
</head>
<body onLoad="doIt();">
<form>
<select>
<option>sample</option>
<option>sample2</option>
</select>
</form>
</body>
</html>
This is the standard method, and will work with all browsers starting at Netscape 4. I will let you look up how to add a value yourself.
PS.. *hint* removing an item is replacing with null
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jun 2004
Status:
Offline
|
|
Thanks to Larkost for pointing me in the right direction.
Here is the code (for posterity - or any other reason) showing how dropdowns can be re(built) so that all platforms can get along (would it be this was effective on humans...)
for (x=0;x<arr1Services.length;x++)
{ thisObject = new Option(Trim(arr1Services[x]));
thisObject.value = Trim(arr1Services[x])
self.document.forms(0).drpServiceID.options [self.document.forms(0).drpServiceID.options.length]=thisObject
}
devilishly straightforward.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |