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

Form submitting to itself

New Here ,
Dec 21, 2006 Dec 21, 2006

Copy link to clipboard

Copied

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.

TOPICS
Advanced techniques

Views

787

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
LEGEND ,
Dec 21, 2006 Dec 21, 2006

Copy link to clipboard

Copied

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

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
New Here ,
Dec 21, 2006 Dec 21, 2006

Copy link to clipboard

Copied

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.

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 ,
Dec 21, 2006 Dec 21, 2006

Copy link to clipboard

Copied

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.

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
New Here ,
Dec 21, 2006 Dec 21, 2006

Copy link to clipboard

Copied

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.

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
LEGEND ,
Dec 21, 2006 Dec 21, 2006

Copy link to clipboard

Copied

what are the value attributes of your cfinput tags?

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
New Here ,
Dec 21, 2006 Dec 21, 2006

Copy link to clipboard

Copied

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>

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 ,
Dec 21, 2006 Dec 21, 2006

Copy link to clipboard

Copied

I would change all of the form and input tags to use CFFORM and CFINPUT , as it will give better formatting and validation.

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
New Here ,
Dec 21, 2006 Dec 21, 2006

Copy link to clipboard

Copied

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.

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
LEGEND ,
Dec 21, 2006 Dec 21, 2006

Copy link to clipboard

Copied

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.


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
LEGEND ,
Dec 21, 2006 Dec 21, 2006

Copy link to clipboard

Copied

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

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 ,
Dec 21, 2006 Dec 21, 2006

Copy link to clipboard

Copied

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.

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
New Here ,
Dec 28, 2006 Dec 28, 2006

Copy link to clipboard

Copied

LATEST
tapping-

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

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