Solved

Variables can be outputted on page using cfdump or cfout but cannot be used in a cfform type=hidden.

Posted on 2011-03-03
14
1,031 Views
Last Modified: 2012-05-11
Hi there.

I am navigating a cfdiv to a certain page with the following command and querystring.

ColdFusion.navigate('components/Doing.cfm?aid=#ActivityQuery.ActivityID#&bid=ExpandedButtons','ExpandedButtons');

The cfdiv sections update properly and I can do a cfoutput and put #url.aid# and #url.bid# in between and the values are displayed properly.

However, when I use it in the following context, it throws an error saying that the variable does not exist.

<cfinput type="hidden" name="aid" value="#url.aid#">

Error: Element AID is undefined in URL

Does anyone know how I can make the variable exist when putting it into a hidden field of the form so that the page that receives the form post would have a copy of this variable/value?

Thaks in advance.
0
Comment
Question by:SFTProd
  • 7
  • 7
14 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 35031633
Works ok for me.  Did you wrap the ColdFusion.navigate(...) call in a cfoutput?

Test.cfm
<cfset ActivityQuery.ActivityID = 123>
<form>
<cfoutput>
	<input type="button" value="Test" onClick="ColdFusion.navigate('components//Doing.cfm?aid=#ActivityQuery.ActivityID#&bid=ExpandedButtons','ExpandedButtons')">
</cfoutput>		
</form>
<cfdiv id="ExpandedButtons" />

Open in new window


components//Doing.cfm
<!--- display variables passed --->
<cfdump var="#URL#">
<cfform>
	<cfoutput>
	aid = #url.aid# 
	bid = #url.bid# 
	</cfoutput>
	<cfinput type="hidden" name="aid" value="#url.aid#">
	<cfinput type="hidden" name="bid" value="#url.bid#">
</cfform>

Open in new window


0
 

Author Comment

by:SFTProd
ID: 35031675
The coldfusion.navigate part works properly.

It's the part that I use the variable in the form that does not work.  When I use it like below, it said the variable does not exist but when I output "url.aid" in cfoutput or cfdump, it works fine.

<cfinput type="hidden" name="aid" value="#url.aid#">

Thanks in advance.
0
 

Author Comment

by:SFTProd
ID: 35031682
I almost forgot to mention.  The error is thrown when I try to submit the form.  If I don't submit the form, it doesn't complain.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35031697
Yeah, I understand.  But if you don't use a cfoutput it may work - but won't pass the correct variables.  So are you using cfoutput?

Also, put a CFDUMP at the very top of your page like in my example.  So you can see what variables are being passed.  What's the result?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35031709
The error is thrown when I try to submit the form.  

That sounds like a totally different issue then.  Post your form code and the full error message.
0
 

Author Comment

by:SFTProd
ID: 35031729
When I do the cfoutput like the following, it works.

<cfoutput>
  aid = #url.aid#
  bid = #url.bid#
</cfoutput>

When I submit the form with these 2 fields in it, the it throws the exception.

<cfinput type="hidden" name="aid" value="#url.aid#">
<cfinput type="hidden" name="bid" value="#url.bid#">

When the form is not submitted, it looks good.  

Before ajax, I used to do this all the time without problems.  I'm not sure why it is throwing an exception when I try to do the same exact thing but within a cfdiv.
0
 

Author Comment

by:SFTProd
ID: 35031803
As a recap, this is how I have it working.

Main Page
<a href="javascript:ColdFusion.navigate('components/target.cfm?aid=#ActivityQuery.ActivityID#&bid=ExpandedButtons','ExpandedButtons');">Show Hidden Area</a>

<cfdiv id="ExpandedButtons" bind="url:components/Blank.cfm"></cfdiv>

target.cfm
<cfform>
  <cfinput type="text name="name">
  <cfinput type="hidden" name="bid" value="url.bid">
  <cfinput type="hidden" name="aid" value="url.aid">
  <cfinput type="Submit" name="SubmitButton" Value="Submit">
</cfform>

After I click on the submit button, it complains that the bid and aid is not defined. However, if I output the value on the page where the form resides either using a cfoutput or a cfdupm, the values display correctly.  The problem appears to be transitioning it into a hidden form field so the target page (action url) will have the copy of this variable.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 52

Expert Comment

by:_agx_
ID: 35031852
<cfform>

Well if you're using a form POST (default) then the values are passed in the FORM scope, not URL. So "url.aid" wouldn't exist but form.aid would be.  
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35031858
If you want the values to be passed in the URL scope then use <cfform method="get">
0
 

Author Comment

by:SFTProd
ID: 35031898
The problem is not whether it is posted as get or post.  The problem is that the values of aid and bid is not being translated into the hidden form fields.  The page that the form is submitting to is not doing any processing.  Once the submit is clicked, the error is thrown before anything else happens.
0
 

Author Comment

by:SFTProd
ID: 35031917
Basically, the main page does a coldfusion.navigate to loado up the form in the cfdiv section.

The cfdiv section contains a form with three fields.  Two of the three fields are hidden fields that try to pass the aid and bid form values to the following page.  The following page does not do any processing.  Once the submit button is clicked, it just throws the exception that the aid and bid variables do not exist when they clear do exist.
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 35031971
The problem is that the values of aid and bid is not being translated into the hidden form fields.

No, that's not what you said before:

"    After I click on the submit button, it complains that the bid and aid is not defined
   ... if I output the value on the page where the form resides either using a cfoutput or a cfdupm, "

If you're posting to the SAME page, it'll work the first time because ColdFusion.navigate passes the values in the URL scope

      ColdFusion.navigate('components/target.cfm?aid=#ActivityQuery.ActivityID

Once you submit the form using method="post", the URL variables go away and what you're submitting is FORM variables NOT url variables.

         form.aid
         form.bid

Also, did you see my questions:
1) CFDUMP the URL and FORM scope. What's the results?
2) What's the error message
0
 

Author Comment

by:SFTProd
ID: 35032053
I traced it again and noticed that I forgot to do a "<cfabort>" before the </cfif>.  As a result, it re-executed the code that references a url variable that does not exist.

Thanks for your help.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35032123
I don't know how much help I was here ... but glad you figured it out.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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

17 Experts available now in Live!

Get 1:1 Help Now