![]() |
| Handling spaces in a form field |
|
cbsinet.com
|
I made a mail script in ColdFusion to mimmick sendmail.pl/formmail.pl to replace the perl scripts some of our clients used. The problem is that the form fields have spaces in some of the names and I can't seem to filter it out.
Any replies on this subject would be appreciated. For now I just don't include that field but it's not a viable option. I either need to learn to support these or go change all the forms for over 100 clients. I never would've done the forms this way but I'm picking up where someone else left off. Not me! I didn't do it! Thanks! |
||||||||||||
|
|
|||||||||||||
|
Josh
Forum Regular
|
couldn't you just do a Replace?
|
||||||||||||||
|
|
|||||||||||||||
|
cbsinet.com
|
I'm not sure about that.
I use a CFLOOP with Form.FieldNames in the LIST arguement and I don't know how that code would fit in. The problem would come in the Evaluate function I use to try and get the value. It makes sense I can't get a value from a variable with a space in it. |
||||||||||||
|
|
|||||||||||||
|
steve
HostMySite Developer
|
In this case the Form variable is a structure so you can use the StructFind function to get the value of the form field.
It might look something like this:
-Steve |
||||||||||||||
|
|
|||||||||||||||
|
loftboy
Forum Regular
|
u should always trim formfields
#trim(form.field)# |
||||||||||||
|
|
|||||||||||||
|
kbrocx
|
Correct me if I'm wrong, but are you saying that the form filed names have spaces in them? As in "My Field"?
Trimming will only remove the spaces from the beginning and end of the variables value. It won't do anything for the varible name itself. Whew, sorry you had to take that job over from someone! If that is the case I'd just grit my teeth and change all those forms. Leaving the spaces in a variable name is just not a good option. Get real comfortable with Search and Replace! |
||||||||||||
|
|
|||||||||||||
|
bobclingan
Forum Regular
|
Recall that form fields are stored in a structure you can also reference the variables like this:
Hope this helps! |
||||||||||||||
|
|
|||||||||||||||
|
byron
Forum Admin
|
Even better, get real comfortable with RegEx find and replace
|
||||||||||||
|
|
|||||||||||||
|
loftboy
Forum Regular
|
duh, i misread the ?
yeah u can always do some converting but thats pretty bad coding practice. Im assuming u want to do this so u can use some java to validate the fields and u dont want it to look like firstName is a required field but u want it to look like first Name is a required field heres your solution, use a different extension, lol or handwrite the variables for the java and properly name your fields |
||||||||||||
|
|
|||||||||||||
|
cbsinet.com
|
I solved the problem by referencing the FORM structure.
It's kind of neat to be able to name the form fields something stupid and still get the values. I personally don't name the fields with spaces but instead I might use an underscore and then replace it when viewing it is needed. Other people made these forms for me to mail out. It was a good learning experience for me. Structures and me get along nicely now. Thanks everyone for your help. |
||||||||||||
|
|
|||||||||||||
| Handling spaces in a form field |
|
||
|


