Solved

Javascript Code - Line by Line, How Does This Work?

Posted on 2014-02-24
5
209 Views
Last Modified: 2014-02-24
I'm working on someone else's project and I know just enough about JavaScript to be frustrated...

Here's the code that exists as well as my "explanation" as to what's going on. If I could have someone fill in the gaps and correct me where I'm wrong, I would appreciate it.

<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</span>//here's where I'm getting a little fuzzy. Looks like several variables that are getting ready to be passed into a form to be evaluated in some way


&nbsp;&middot;&nbsp;<span class='clickableLite' onmouseover="this.style.textDecoration='underline';"
onmouseout="this.style.textDecoration='none';"
onclick='clearfield(dataform,"physicianid","physician",physicianname,"physician")'>clear all</span>//same kind of thing as above.

Open in new window


Now here's the loadlookup function being called...

function loadlookup(form, page, entityid, id, name, label) {// here are the variables that this function is going to be evaluating

	lookuplabel.innerHTML = '<span class=\'legend\'>Click name to add:</span>  '+label; // it looks as though that when the user clicks on the above link, part of the task that the activated function is going to be doing includes the assertion of a line of text, which in this case is, "Click name to add:"


	lookupentity = form.entityid.value; /I'm thinking this is the dynamic that defines the "label" variable referenced above, but where is "form.entityid.value" coming from?

	switch (label) {
		case "physician" :
			groupid = form.specialtyid.value;
			break;
		case "payer" :
			groupid = form.finclassid.value;
			break;
		default :
			groupid = "";
			break;
		}

Open in new window


If someone could confirm and / or correct what I've got above in terms of comments and then add whatever else I may be missing, I would appreciate it.
0
Comment
Question by:brucegust
  • 2
  • 2
5 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39883723
This would be easier if you just posted the full elements HTML and the full js functions, instead of bits of everything that just makes it look like a mess.
0
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 39883897
To answer (literally) the code takes as input 5 parameters of which we can guess that from refers to a form on the page and the rest is a bit more vague.

Line 2
Sets the html content of the lookuplabel - although it is not possible to tell where lookuplabel comes from or where it is defined or why it is being set as it is.

Line 3
sets lookupentity to the value of the entityid field on the form (example<input> element)

Line 4
Starts a switch statement based on the label parameter. From the posting there appear to be 2 possibilities - physician and payer

In the case of physician the groupid variable (unclear as to where it is defined or how it is used) is assigned the value of the from element specialityid.

In the case of payer groupid is assigned the value of the form element finclassid.

In answer to your question in your comment
where is "form.entityid.value" coming from
The answer is entityid is a form element with an id of entityid.

That is all we can tell from what you have posted.
0
 

Author Comment

by:brucegust
ID: 39883992
Yeah, it would. But all I've got is screen shots. I can upload those if you like, but I don't have the actual HTML code.
0
 

Author Comment

by:brucegust
ID: 39883997
Julian, that gives me what I need at this point.

Thanks!
0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 39884013
You are welcome - thanks for the points.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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

18 Experts available now in Live!

Get 1:1 Help Now