I'm a JavaScript newbie (and new to thescripts.com too). And I have problems in working with objects in JavaScript.
The problem:
[HTML]<a href="javascript:functionName(object);">Click me</a>[/HTML]
Somehow it calls toString for the object and rather than it being processed as an object, it is processed as a string.
Details:
I'm trying to build a documentation UI (using VBA plugin mztools) and the objects I work with are Project, File, Procedure in that order. The Procedure in turn has arrays of Comments and Parameters.
Expand|Select|Wrap|Line Numbers
- function File(Name,Files) {
- this.Name=Name;
- this.Files=Files
- }
- function File(some arguments....,Procedures) {
- // The usual this statements...
- }
I'm able to build a library (not sure if the term is correct) of objects where the Projects array is the parent / reference array I keep referring to.
Now, dynamically, the href of anchors is modified. What I want it to have is:
javascript:functionName(object)
But what gets called is:
javascript:functionName("[object Object]")
I tried using typeOf within "functionName" ...but couldn't figure out what to do with it. Also, I cannot re-construct the object (say Procedure) again from the toString output for it, since there are many more things about it which functionName doesn't know about.
What should my approach be in such a case ? Thank you in advance for all your inputs.