Solved

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

Posted on 2014-02-24
5
211 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 54

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 54

Expert Comment

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

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

770 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