9 Replies Latest reply on Jul 11, 2006 11:02 PM by Newsgroup_User

    Capturing a URL varible to a hidden field

    Level 7
      I am trying to pass 2 variables to a hidden fields on the next page. I then
      want to use them in the code after then submit button is clicked.

      I passed the 2 variables correctly though the URL and can capture one for
      text on the page using:
      <cfoutput>#URL.username#</cfoutput>

      However, they are not working in the hidden fields. I have:

      <cfoutput><input name="username" type="hidden" id="username"
      value="#URL.username#" /> <input name="email" type="hidden" id="email"
      value="#URL.email#" /></cfoutput>

      Please help!

      --
      Wally Kolcz
      Developer / Support
      ProjectProofing.com


        • 1. Re: Capturing a URL varible to a hidden field
          Level 7
          No obvious errors here, how is this "not working?" What incorrect
          behavior|errors is happening?

          Wally Kolcz wrote:
          > I am trying to pass 2 variables to a hidden fields on the next page. I then
          > want to use them in the code after then submit button is clicked.
          >
          > I passed the 2 variables correctly though the URL and can capture one for
          > text on the page using:
          > <cfoutput>#URL.username#</cfoutput>
          >
          > However, they are not working in the hidden fields. I have:
          >
          > <cfoutput><input name="username" type="hidden" id="username"
          > value="#URL.username#" /> <input name="email" type="hidden" id="email"
          > value="#URL.email#" /></cfoutput>
          >
          > Please help!
          >
          • 2. Re: Capturing a URL varible to a hidden field
            Level 7
            On the IsDefined('Submit') I have:
            <cfdirectory action="CREATE"
            directory="E:\webs\mywebsite.com\#form.username#">

            It keeps coming up with the literal #FORM.username# and creates a folder
            called #form.username# verses the value that is captured in the hidden
            field.

            When I switch it to #URL.username# it seems to work.


            • 3. Re: Capturing a URL varible to a hidden field
              Level 7
              What is the method parameter on the form page. If method is "get" then
              you are sending the data as URL data not Form data which is method="post"

              Wally Kolcz wrote:
              > On the IsDefined('Submit') I have:
              > <cfdirectory action="CREATE"
              > directory="E:\webs\mywebsite.com\#form.username#">
              >
              > It keeps coming up with the literal #FORM.username# and creates a folder
              > called #form.username# verses the value that is captured in the hidden
              > field.
              >
              > When I switch it to #URL.username# it seems to work.
              >
              >
              • 4. Re: Capturing a URL varible to a hidden field
                Level 7
                Agreed, but if I were to capture the URL variable into a hidden field,
                wouldn't that make it a form variable to which I could use Form.?


                • 5. Re: Capturing a URL varible to a hidden field
                  Level 7
                  NOPE. What the values of a form are returned to the server as is solely
                  determined by the method parameter of the form.

                  Some code you can play with that might clear this up.

                  <cfsilent>

                  <cfparam name="url.Field" default="">
                  <cfparam name="form.Field" default="">

                  </cfsilent><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
                  Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                  <html xmlns=" http://www.w3.org/1999/xhtml">
                  <head>
                  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                  <title>Form Methods</title>
                  </head>

                  <body>
                  <h1>Form Methods</h1>

                  <h2>Get</h2>
                  <cfoutput>
                  <form method="Get">
                  <input type="text" name="Field" value="#form.field#" />
                  <input type="submit" />
                  </form>

                  <h2>Post</h2>
                  <form method="post">
                  <input type="text" name="Field" value="#url.Field#" />
                  <input type="submit" />
                  </form>
                  </cfoutput>
                  </body>
                  </html>

                  Wally Kolcz wrote:
                  > Agreed, but if I were to capture the URL variable into a hidden field,
                  > wouldn't that make it a form variable to which I could use Form.?
                  >
                  >
                  • 6. Re: Capturing a URL varible to a hidden field
                    Kronin555 Level 1
                    if your form's method is GET, then you access the variables using URL._____
                    if your form's method is POST, then you access the variables using FORM._____
                    • 7. Re: Capturing a URL varible to a hidden field
                      Level 7
                      To follow up, when submitting the Get form, notice that the value is now
                      in the URL of the page.

                      Ian Skinner wrote:
                      > NOPE. What the values of a form are returned to the server as is solely
                      > determined by the method parameter of the form.
                      >
                      > Some code you can play with that might clear this up.
                      • 8. Re: Capturing a URL varible to a hidden field
                        Level 7
                        I understand what you mean. Thanks.

                        Is it possible to reference a hidden variable after it has captured its
                        value from the URL?

                        If I have my hidden variable 'email' set to =#URL.email# can I reference
                        that in a <cfmail> after the form is submitted?
                        <cfoutput><input name="email" type="hidden" id="email" value="#URL.email#"
                        /></cfoutput>

                        Or is it better to just <cfset emailfrom = #URL.email#> then use that in the
                        <cfmail> area after the form is submitted?

                        I have the form set to:
                        <cfif IsDefined('submit')>
                        Create Dyanmic Folder
                        Copy File Into Folder
                        Send Email with attachent
                        INSERT form into database
                        UPDATE another database
                        Redirect to 'thank you page'
                        </cfif>


                        • 9. Re: Capturing a URL varible to a hidden field
                          Level 7
                          Oh, btw, the form is set to 'post' and the Form. was not working..

                          That is why I am confused.

                          Thanks