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

How to submit a form to itself?

Enthusiast ,
Mar 17, 2016 Mar 17, 2016

Copy link to clipboard

Copied

I have a cfform on the page. When I submit the form, I want to submit it to self. Another word, I do not want to submit to another .cfm page. So, how do I do it?

Views

3.1K

Translate

Translate

Report

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

Guide , Mar 17, 2016 Mar 17, 2016

If you omit the action attribute, it should submit to itself.

Votes

Translate

Translate
Advocate ,
Mar 17, 2016 Mar 17, 2016

Copy link to clipboard

Copied

It's dated but I think it still applies. I wrote a tutorial on this several years back: EasyCFM.COM - View Tutorial

Hope this helps.

Votes

Translate

Translate

Report

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
Guide ,
Mar 17, 2016 Mar 17, 2016

Copy link to clipboard

Copied

If you omit the action attribute, it should submit to itself.

Votes

Translate

Translate

Report

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
Enthusiast ,
Mar 17, 2016 Mar 17, 2016

Copy link to clipboard

Copied

Cool! I'll test that tomorrow. Does that apply to all browsers or only certain browser?

Votes

Translate

Translate

Report

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
Guide ,
Mar 17, 2016 Mar 17, 2016

Copy link to clipboard

Copied

I think that's rudimentary <form> behavior, so it should work in all browsers.

Votes

Translate

Translate

Report

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
Enthusiast ,
Mar 18, 2016 Mar 18, 2016

Copy link to clipboard

Copied

Okay, if I omit the action attribute, it's not doing anything...at least that's under Firefox.

Votes

Translate

Translate

Report

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
Advocate ,
Mar 18, 2016 Mar 18, 2016

Copy link to clipboard

Copied

You are usually required to have the action attribute but you can just set it to nothing.

<cfform action="">

BKBKs suggestion is a valid option too

AS per cfform docs -

If you omit this attribute and the method is get, the form posts to the page identified by the CGI.SCRIPT_NAME variable (the requested page that resulted in displaying the form). If the method is post, the form posts to the page identified by the CGI.QUERY_STRING variables.

Votes

Translate

Translate

Report

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
Enthusiast ,
Mar 18, 2016 Mar 18, 2016

Copy link to clipboard

Copied

Something odd about my form. The submit do not submit the form at all. I've put in the URL for the action attribute and it's still not working. Below is my form:

<cfform name="koComments" action="#actionURL#">

  <div class="row">

      <div class="large-12 medium-12 columns">

        <div class="row" data-equalizer>

            <div class="large-4 medium-4 columns">

              <div class="row">

                  <div class="large-12 columns">

                    <label>

                        <cfinput type="text" placeholder="Name" name="name" required="true" >

                    </label>

                    <small class="error">Name is required and must be a string.</small>

                  </div>

              </div>

              <div class="row">

                  <div class="large-12 columns">

                    <label>

                        <cfinput type="text" placeholder="Email" name="mailfrom" required="true" pattern=".*@.*\..{3}|.*@.*\..{2}" >

                    </label>

                    <small class="error">An email address is required.</small>

                  </div>

              </div>

              <div class="row">

                  <div class="large-12 columns">

                    <div class="g-recaptcha" data-sitekey="6LfjNwITKBDKJPbDHdC5wx6HXRmXtqO3pgUItl-E"></div>

                    <noscript>

                        <div style="width: 302px; height: 462px;">

                          <div style="width: 302px; height: 422px; position: relative;">

                              <div style="width: 302px; height: 422px; position: absolute;">

                                <iframe src="https://www.google.com/recaptcha/api/fallback?k=6LfjNwITKBDKJPbDHdC5wx6HXRmXtqO3pgUItl-E"

                                    frameborder="0" scrolling="no"

                                    style="width: 302px; height:422px; border-style: none;">

                                </iframe>

                              </div>

                          </div>

                          <div style="border-style: none; bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px; background: ##f9f9f9; border: 1px solid ##c1c1c1; border-radius: 3px; height: 100px; width: 300px;">

                              <cfinput id="g-recaptcha-response" name="g-recaptcha-response" type="text" class="g-recaptcha-response" style="width: 280px; height: 80px; border: 1px solid ##c1c1c1; margin: 10px; padding: 0px; resize: none;" >

                          </div>

                        </div>

                        <br /><br />

                    </noscript>

                  </div>

              </div>

            </div>

            <div class="large-8 medium-8 columns">

              <div class="row">

                  <div class="large-12 columns">

                    <cfinput type="text" name="message" placeholder="Leave a comment...we love feedback!" rows="5" required="true" >

                  </div>

              </div>

              <div class="row">

                  <div class="large-12 columns">

                    <cfinput type="button" name="submit" class="tiny right" value="Submit" >

                  </div>

              </div>

            </div>

        </div>

      </div>

  </div>

</cfform>

Votes

Translate

Translate

Report

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
Enthusiast ,
Mar 18, 2016 Mar 18, 2016

Copy link to clipboard

Copied

Okay, since the submit button does not work, I have another question. Do I need to use CFFORM and CFINPUT if it's just a simple form? The only thing I need is able to grab all the form values in the same page and then do a cfhttp to a json api.

Votes

Translate

Translate

Report

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
Advocate ,
Mar 18, 2016 Mar 18, 2016

Copy link to clipboard

Copied

If it was me, I would never use cfform. Best sticking to the normal form and inputs and avoid issues with coldfusion altogether. Then you can just use the form scope on the page it posts to.

Votes

Translate

Translate

Report

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
Enthusiast ,
Mar 18, 2016 Mar 18, 2016

Copy link to clipboard

Copied

Okay, I found the problem. The cfinput type should be "Submit" and not "button". That resolves it. And yes, omitting the action attribute value works...at least in Firefox.

Thank you, all!

Votes

Translate

Translate

Report

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 ,
Mar 18, 2016 Mar 18, 2016

Copy link to clipboard

Copied

I would avoid using CFForm all together.  It offers you nothing but a boat load of extra js loaded in and possible headache later.  There are much better ways do what it can do for you.

Votes

Translate

Translate

Report

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
Enthusiast ,
Mar 18, 2016 Mar 18, 2016

Copy link to clipboard

Copied

If I don't use the cfform and just use regular form and input, can I still do this: #form.message# and it will give me the value of the textbox named "message"?

Votes

Translate

Translate

Report

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
Advocate ,
Mar 18, 2016 Mar 18, 2016

Copy link to clipboard

Copied

yes the form scope is still available with a normal html form

Votes

Translate

Translate

Report

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
Enthusiast ,
Mar 18, 2016 Mar 18, 2016

Copy link to clipboard

Copied

LATEST

Awesome! Thank you so much for the help. I'l definitely give that a try.

Votes

Translate

Translate

Report

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
Community Expert ,
Mar 17, 2016 Mar 17, 2016

Copy link to clipboard

Copied

Old school: action="#CGI.SCRIPT_NAME#"

Votes

Translate

Translate

Report

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
Documentation