12 Replies Latest reply on Dec 28, 2006 12:04 PM by cpayne624

    Form submitting to itself

    tapping
      I have a form that submits to itself. When there is a server-side error, for ex. a key value is already in the database table, when the form comes back with the error message on the screen, the values move over in the entries and sometimes the numbers or letters on the end or beginning of the values are missing. What can I do to prevent this from happening? I am using Firefox and Internet Explorer for my browsers.

      Thank you for any advice you can give me.

        • 1. Re: Form submitting to itself
          Dan Bracuk Level 5
          The best way to handle the effects of a server side error is to prevent the server side error. If the error pertains to inserting a record that is already there, there are many ways to prevent that. Here is one.

          insert into yourtable
          (yourfields)
          select distinct yourvalues
          from some_small_table
          where (select count(*)
          from yourtable
          where some conditions are met) = 0
          • 2. Re: Form submitting to itself
            tapping Level 1
            It really does not pertain to a record that is already there. This was just an example.

            I am talking about my edit checks that I wrote when I speak of a server side error.

            The problem is that the values in the form entries are truncated. For example, I have a phone number I entered that is 10 digits. After I submit the form the last digit is gone and the phone number moves over a space in the form entry. Other number entries do the same like the SSN number. Seems like only the numbers get truncated.

            I am using Firefox and Internet Explorer

            THank you for your reply.
            • 3. Re: Form submitting to itself
              insuractive Level 3
              How are you returning the data to the form? Does the page self-post? maybe posting some code samples might help diagnose what's going wrong.
              • 4. Re: Form submitting to itself
                tapping Level 1
                The following is the HTML form code -

                <td><form name="loanapplication"action="loanapplication.cfm" method="post" target = "_self" onSubmit="return validate(document.loanapplication);"></td>

                If you need any other code, please let me know.

                Thank you for your reply.
                • 5. Re: Form submitting to itself
                  Dan Bracuk Level 5
                  what are the value attributes of your cfinput tags?
                  • 6. Re: Form submitting to itself
                    tapping Level 1
                    Below is a text box for a SSN number:

                    <input name="ssn1" type="text" id="ssn1" <cfif isdefined("form.ssn1")>
                    value = "<cfoutput> #form.ssn1#</cfoutput>" <cfelse> value = "<cfoutput>***</cfoutput>"</cfif>size="3" maxlength="4" onKeyUp ="validotherssn(this);" onKeypress="if (event.keyCode < 48 || event.keyCode > 57 ) event.returnValue = false;" />
                    <input name="ssn2" type="text" id="ssn2" <cfif isdefined("form.ssn2")>value = "<cfoutput> #form.ssn2#</cfoutput>"<cfelse> value = "<cfoutput>**</cfoutput>" </cfif>
                    size="2" maxlength="3" onkeyup="validotherssn(this);" onKeypress="if (event.keyCode < 48 || event.keyCode > 57 ) event.returnValue = false;" />
                    <input name="ssn3" type="text" id="ssn3" <cfif isdefined("form.ssn3")>value = "<cfoutput> #form.ssn3#</cfoutput>" <cfelse> value = "<cfoutput>****</cfoutput>"</cfif> onKeyUp="validotherssn(this);" size="4" maxlength="5" onKeypress="if (event.keyCode < 48 || event.keyCode > 57 ) event.returnValue = false;" /> </td>
                    • 7. Re: Form submitting to itself
                      Abinidi
                      I would change all of the form and input tags to use CFFORM and CFINPUT , as it will give better formatting and validation.

                      • 8. Re: Form submitting to itself
                        tapping Level 1
                        I changed my form to cfform and all my input tags to cfinput. I am getting the following error message on all text box entries.

                        Invalid token 'c' found on line 1488 at column 228.

                        The CFML compiler was processing:

                        * a cfinput tag beginning on line 1488, column 12.


                        The error occurred in D:\Testing WEB\loanapplicationtwo.cfm: line 1488

                        1486 : <tr>
                        1487 : <td height="40"><strong>Cash Price <span class="style8">*</span></strong></td>
                        1488 : <td><cfinput type="text" name="cashprice" id="cashprice" onKeyUp="valid(this);" onKeyPress="if (event.keyCode != 46 && event.keyCode < 48 || event.keyCode > 57 ) event.returnValue = false;" size="10" maxlength="10" <cfif isdefined("form.cashprice")>value = "<cfoutput> #form.cashprice#</cfoutput>" <cfelse>value="0.00"</cfif> >
                        1489 : </td>
                        1490 : </tr>

                        I have never used CFform. Why am I getting this message on all text fields?

                        Thank you.
                        • 9. Re: Form submitting to itself
                          Level 7
                          The "less then" and "greater then" signs (<|>) in your inline JS is
                          confusing the parser which is thinking they are opening or closing angle
                          brackets (<|>).

                          If you want to keep the <cfinput...> tags move your JS into a function
                          in a script block then call that function from the tags.


                          • 10. Re: Form submitting to itself
                            Dan Bracuk Level 5
                            You can't nest cftags like this:

                            <cftag1 <cftag2>>

                            You have to do this
                            <cftag1>
                            <cftag2>
                            </cftag1>
                            </cftag2>

                            Life would be a lot simpler if your rearranged your code. All the if/else and other logical code could be written first. The resulting variables are then used for the value attributes of your form
                            • 11. Re: Form submitting to itself
                              azadisaryev Level 1
                              As noted by Dan, you can't nest cf tags inside cf tags.
                              What you can do in your case, is change <cfinput to just <input on those tags that you need to use <cfif> in. You can still keep the form tag as <cfform> - it supports regular <input> tags just fine.
                              • 12. Re: Form submitting to itself
                                cpayne624
                                tapping-

                                To resolve your original issue, remove the SPACE immediately following the opening quote in the VALUE attribute of your form inputs.