• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1201
  • Last Modified:

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

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
SFTProd
Asked:
SFTProd
  • 7
  • 7
1 Solution
 
_agx_Commented:
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
 
SFTProdAuthor Commented:
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
 
SFTProdAuthor Commented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
_agx_Commented:
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
 
_agx_Commented:
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
 
SFTProdAuthor Commented:
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
 
SFTProdAuthor Commented:
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
 
_agx_Commented:
<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
 
_agx_Commented:
If you want the values to be passed in the URL scope then use <cfform method="get">
0
 
SFTProdAuthor Commented:
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
 
SFTProdAuthor Commented:
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
 
_agx_Commented:
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
 
SFTProdAuthor Commented:
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
 
_agx_Commented:
I don't know how much help I was here ... but glad you figured it out.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 7
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now