...

View Full Version : I need to convert a string into an object? How.



jcperryman
08-28-2006, 12:07 AM
I have always found you all to be very helpful, so let me say thank you in advance - thank you.

I have a functions: some(objectId) and another(objectIdString).
Now another() needs to call some() but objectIdString is not what some() needs.

Now how do I, if possable, convert a string to its object equifalent?
In some places I have used eval() and it seemed to work.
Ok my friends, what o you suggest.

Joseph - greatful for any help I can get.

Kravvitz
08-28-2006, 04:42 AM
If the string is really the unique ID of an element, you should do this:

some(document.getElementById(objectIdString))
I suggest you read up on the Document Object Model (DOM):
JavaScript tutorial - W3C DOM introduction (http://www.howtocreate.co.uk/tutorials/javascript/domintroduction)
http://www.quirksmode.org/dom/
http://www.quirksmode.org/js/dom.html
http://www.brainjar.com/
http://developer.apple.com/internet/webcontent/dom2i.html
http://developer.mozilla.org/en/docs/DOM:document
http://developer.mozilla.org/en/docs/Gecko_DOM_Reference
http://www.sitepoint.com/article/rough-guide-dom
http://digital-web.com/articles/forms_usability_and_the_w3c_dom/
http://www.w3.org/DOM/

jcperryman
08-28-2006, 05:02 AM
Hello sir,

Thank you very much for your wonderful suggestions.
I have actually seen that code before but it did not come to mind.
Thank you it will work just fine.

Joseph - must be a newbie



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum