Highlighted

How to submit a form to itself?

Engaged ,
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?

Most Valuable Participant
Correct answer by Carl_Von_Stetten | Most Valuable Participant

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

Views

1.6K

Likes

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

How to submit a form to itself?

Engaged ,
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?

Most Valuable Participant
Correct answer by Carl_Von_Stetten | Most Valuable Participant

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

Views

1.6K

Likes

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
Mar 17, 2016 0
Advocate ,
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.

Likes

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
Reply
Loading...
Mar 17, 2016 1
Most Valuable Participant ,
Mar 17, 2016

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Mar 17, 2016 0
Engaged ,
Mar 17, 2016

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Mar 17, 2016 0
Most Valuable Participant ,
Mar 17, 2016

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Mar 17, 2016 0
Engaged ,
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.

Likes

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
Reply
Loading...
Mar 18, 2016 0
Advocate ,
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.

Likes

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
Reply
Loading...
Mar 18, 2016 1
Engaged ,
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>

Likes

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
Reply
Loading...
Mar 18, 2016 0
Engaged ,
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.

Likes

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
Reply
Loading...
Mar 18, 2016 0
Advocate ,
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.

Likes

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
Reply
Loading...
Mar 18, 2016 0
Engaged ,
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!

Likes

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
Reply
Loading...
Mar 18, 2016 0
Engaged ,
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.

Likes

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
Reply
Loading...
Mar 18, 2016 0
Engaged ,
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"?

Likes

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
Reply
Loading...
Mar 18, 2016 0
Advocate ,
Mar 18, 2016

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Mar 18, 2016 1
2Charlie LATEST
Engaged ,
Mar 18, 2016

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Mar 18, 2016 0
Adobe Community Professional ,
Mar 17, 2016

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Mar 17, 2016 0