Solved

What would this ColdFution Function means

Posted on 2015-02-23
6
94 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
Comment Utility
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
Comment Utility
(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
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 250 total points
Comment Utility
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 250 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 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

8 Experts available now in Live!

Get 1:1 Help Now