• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

Another question about a Javascript form

I have a hard time accepting "that" something works, I need to know "why" in order to feel like I really understand what's going on. That said, I've got a question about a JavaScript form:

<span onmouseover="this.style.textDecoration='underline';"
onmouseout="this.style.textDecoration='none'" //like a link, user sees the "add physician" text underlined when the mouse over it

onclick='loadlookup  //going to call a function when the user clicks on the "add physician" text

(dataform,"physician_lookup",entityid,physicianid,physician,"physician")'>add physician</a>

The above code, from what I'm learning, is a function that is called when the user clicks on "add physician." Thing is, it's not just a function, is it? It's actually instantiating a form object, correct? I'm basing this on http://javascript.about.com/od/hintsandtips/ss/domscriptwalkthrough.htm.

That being the case, I want to understand what "dataform" is. The actual function is:

function loadlookup(form, page, entityid, id, name, label) {
      lookuplabel.innerHTML = '<span class=\'legend\'>Click name to add:</span>  '+label;

The first element being "form," is what defines this as an object versus a mere function, correct? But what is the significance of "dataform" as far as the way it's being called?

I want to be able to get my mental arms around that.
0
brucegust
Asked:
brucegust
  • 2
2 Solutions
 
Carl TawnSystems and Integration DeveloperCommented:
dataform should be a reference to a javascript variable declared elsewhere, which is being passed to the function. I would guess that it is somewhere higher up in the page and probably holds a reference to the <form> element in your page.

If you have a copy of your page available somewhere that we could see then it would be easier to be more specific.
0
 
brucegustPHP DeveloperAuthor Commented:
Carl, you nailed it. I found it as I was going through some code down the page and BOOM! Epiphany! Thanks!
0
 
Julian HansenCommented:
The above code, from what I'm learning, is a function that is called when the user clicks on "add physician."
Correct
Thing is, it's not just a function, is it? It's actually instantiating a form object, correct?
No, it is just a function. Instantiating an object requires the new operator which is not in evidence. The function might create an object but there is no way of telling from the way it is called.
The first element being "form," is what defines this as an object versus a mere function, correct?
Nope - it is just a function.
And as Carl pointed out dataform is just a variable declared somewhere on your page. If it is in quotes or a number it is a value if it is a string without quotes it is a variable declared somewhere else.
0
 
brucegustPHP DeveloperAuthor Commented:
I get it. After looking at the code closer and trying to digest it more, the function isn't instantiating a form as much as it's just compiling the variables that will be used in an iframe down the road. Thanks, guys!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now