Solved

Another question about a Javascript form

Posted on 2014-02-25
4
189 Views
Last Modified: 2014-02-25
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
Comment
Question by:brucegust
  • 2
4 Comments
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 200 total points
ID: 39885891
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
 

Author Comment

by:brucegust
ID: 39885989
Carl, you nailed it. I found it as I was going through some code down the page and BOOM! Epiphany! Thanks!
0
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 300 total points
ID: 39886150
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
 

Author Comment

by:brucegust
ID: 39886232
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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now