Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

What would this ColdFution Function means

Posted on 2015-02-23
6
Medium Priority
?
120 Views
Last Modified: 2015-02-23
Hello,

I am new to ColdFusion and trying to understand this line:
document.requestForm.action='index.cfm?requesttype=' + sh + '&ResetForm=' + ResetFrm;

1) What would the whole line mean?
2) what does the & added to the variable &ResetForm?

Thank you,
RS


function chForm(sh, ResetFrm) 
{
	
	if (ResetFrm == 'y') 
		{
		
			document.requestForm.action='index.cfm?requesttype=' + sh + '&ResetForm=' + ResetFrm;
			
                        document.requestForm.submit();
			return true;		
		}
}

Open in new window

0
Comment
Question by:Rad1
6 Comments
 
LVL 6

Expert Comment

by:rjohnsonjr
ID: 40627210
This looks like javascript to me....  that line is setting the form action="index.cfm?requesttype=sh&ResetForm=ResetFRM"  where sh and ResetFfrm are replaced with the values passed into the function.
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 40627219
(no points)

Agreed, that is not Coldfusion, it is javascript and deos as rjohnson says; it assigns that URL and query string to the form's action.
0
 

Author Comment

by:Rad1
ID: 40627223
what does the & added to the variable &ResetForm? means?

And

Does the below line means Document take action on the index.cfm and the query string ?
document.requestForm.action='index.cfm?requesttype
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 1000 total points
ID: 40627233
ResetForm isn't the variable--ResetFrm is. This code is just a string concatenation operation. The ampersand is a part of the querystring, and it is used to separate each key/value pair from the others. Each key/value (aside from the first) will have an ampersand in front of it.
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 1000 total points
ID: 40627235
This (requestForm) is the name of your form, so this...

   document.requestForm.action

Means that form's action tag as in... <FORM ACTION="xxxx" METHOD="POST">

So, this javascript.. is assigning the action so that when the form posts, it will post to index.cfm.

The parameters of index.cfm are delimted by ? and &  just like on any normal URL.   Look at the URL and you can see the variables.  After the file is always a ? and then between the parameter=value pair you have & separators

SO, the javascript is passing the variable  "requesttype"   and the variable "ResetForm" to index.cfm
If you look into index.cfm you should see these variables.

The value the javascript is giving these two variables is determined by the function calll here:  
function chForm(sh, ResetFrm) .    If you look on the page for a call to   chForm(xxx, yyyy) those are the two values that are being passed to those two variables.   Whatever Xxxx is and yyyy will be put into requesttype and ResetForm respectively.


So, the short version is... look on the page for  this function call:   chForm(xxx, yyyy)   and then go to index.cfm and you will see   url.requesttype getting the value of xxx and url.ResetForm getting the value from yyyy
0
 

Author Closing Comment

by:Rad1
ID: 40627314
Yes, yes, thank you!!!!

That is very true and correct, I think I missed it because of me think of ColdFusion.  
My Bad!!!!

Thank you for the great explanations.

RS
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

876 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