Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > innerText is only an extension?

innerText is only an extension?
Thread Tools
Fresh-Faced Recruit
Join Date: Jun 2004
Status: Offline
Reply With Quote
Jun 11, 2004, 03:50 PM
 
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
Reply With Quote
Jun 11, 2004, 05:52 PM
 
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
Reply With Quote
Jun 14, 2004, 04:36 AM
 
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
Reply With Quote
Jun 14, 2004, 08:46 AM
 
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
     
rokosz  (op)
Fresh-Faced Recruit
Join Date: Jun 2004
Status: Offline
Reply With Quote
Jun 16, 2004, 07:48 PM
 
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.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:35 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2