Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Passing form variables

Guest
May 08, 2007 May 08, 2007
HI~

I have a cfform on my index.cfm page, and the action is set to go to a confirm.cfm page. On that page, I want the user to be able to look at the information they entered into the form, and then hit "Submit" if it is correct. Right now, I am able to display the form information on the confirm.cfm page, but I'm having a hard time with my insert statement. Right now, when I hit the final Submit button, an entry is made in the database, but none of the variables are passed. I'm guessing this is because of the cfparam default="" setting, but I don't know what else to set it as-- if I try to set it as semester or form.semester, it says it is not defined. Please help! Thanks!
TOPICS
Advanced techniques
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , May 09, 2007 May 09, 2007
You need to make sure that the form.semester variable is treated as a variable... use #'s and <cfoutput> tags....

<cfform action="#CGI.SCRIPT_NAME#" name="submitEval" METHOD="post">
<!--- Submit Button that reads "Submit Evaluation" --->
<cfinput type="submit" value="Submit Evaluation" name="submitEval" id="submitEval">
<cfoutput>
<cfinput type="hidden" name="semester" value="#form.semester#">
</cfoutput>
</cfform>

Phil
Translate
Guest
May 08, 2007 May 08, 2007
On the second form, you should add a hidden form field to pass the previous Form variable along.

<cfinput type="hidden" name="semester" value="Form.semester">

So, when you submit the second Form - it will have the value from the first Form. Otherwise, the variable Form.semester does not exist.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 08, 2007 May 08, 2007
Exactly.
It makes it clear if you simply display the form data for review:
<cfoutput>
#form.semester#
</cfoutput>
<cfinput type="hidden" name="semester" value="Form.semester">
Then direct the user back to edit or forward to confirm
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 09, 2007 May 09, 2007
OK... so, do I just need the hidden field, or do I still need the <cfparam> tag?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 09, 2007 May 09, 2007
semi star gazer wrote:
> OK... so, do I just need the hidden field, or do I still need the <cfparam> tag?

you must have a form field (hidden or not) that stores selected/entered
semester from the first form (index page) in your second form (confirm
page), otherwise when that (second) form (is submitted, it does not hold
any reference to the semester inside its scope...

--
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 09, 2007 May 09, 2007
OK, I think I'm still missing something here. This is what I have right now. With this code, I get a blank entry in the database when the user hits the Submit button.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 09, 2007 May 09, 2007
You need to make sure that the form.semester variable is treated as a variable... use #'s and <cfoutput> tags....

<cfform action="#CGI.SCRIPT_NAME#" name="submitEval" METHOD="post">
<!--- Submit Button that reads "Submit Evaluation" --->
<cfinput type="submit" value="Submit Evaluation" name="submitEval" id="submitEval">
<cfoutput>
<cfinput type="hidden" name="semester" value="#form.semester#">
</cfoutput>
</cfform>

Phil
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 09, 2007 May 09, 2007

right on! just no need for <cfoutput> tags around it, #'s are enough...
how did i miss that??? should go to bed now...

anyway, that still does not explain why his form.semester is an empty
string, since, without the #'s, the value of the hidden field will be
literal 'form.semester', and that is what should be inserted into the
db, not an empty string.....

--
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 09, 2007 May 09, 2007
semi star gazer wrote:
> OK, I think I'm still missing something here. This is what I have right now.
> With this code, I get a blank entry in the database when the user hits the
> Submit button.
>
> <cfparam name="form.semester" default="">
>
> <cfif isDefined("form.submitEval")>
>
> <!--- insert form data into database --->
> <cfquery name="insertEval" datasource="intern">
> INSERT INTO mentorEvals (
> semester
> ) VALUES (
> '#Trim(form.semester)#'
> )
> </cfquery>
>
> <cfform action="#CGI.SCRIPT_NAME#" name="submitEval" METHOD="post">
> <cfinput type="hidden" name="semester" value="form.semester">
> <!--- Submit Button that reads "Submit Evaluation" --->
> <cfinput type="submit" value="Submit Evaluation" name="submitEval"
> id="submitEval">
> </cfform>
>

try using <input type="hidden" ...> instead of <cfinput ...> - i seem to
recall there being issues with hidden cfinput fields...

also - where's your closing </cfif>??? it should be after </cfquery> - i
hope it is actually there...

just to make sure semester is passed from first form, you can put
<cfoutput>#form.semester#</cfoutput> right after your <cfparam>

NOTE: you do not really need that <cfparam> there... it does not do
anything... unless you are planning to use it later for validation
routines... i wonder if it may be tampering with the semester value...
it shouldn't, but who knows...

--
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 09, 2007 May 09, 2007
LATEST
Thanks everyone!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources