0
Help with buttons
Participant
,
/t5/coldfusion-discussions/help-with-buttons/td-p/997347
Mar 03, 2008
Mar 03, 2008
Copy link to clipboard
Copied
I have a form with the following three buttons. Originally,
the back and home buttons were images with an a hef tag, and the
second button submitted the form to an action page, after
javascript edits. So I am mixing buttons and images, and everything
works fine.
I have been told to do away with the images and make everything buttons, so I named the three buttons 1, 2, and 3 and sent everything to my action page, and did a cfif isdefined for each button, then did a cflocation url to pass to the apppropriate pages. That works ok.
But is there a way to do it without sending the first and third buttons to the action page, and only send the second one ?
This is what I have so far. The back button works, the second button still submits and validates, but I do not know how to code the third button, which should take me to the page index.cfm, when I click on it.
What is the proper syntax for this ? Thanks
<td align="center">
<INPUT TYPE="button" name="button_1" VALUE=" Back " onClick="history.go(-1)">
</td>
<td align="center">
<input type="button" name="button_2" value=" Upload File " onClick="validateForm(document.upload_form)">
</td>
<td align="center">
<input type="button" name="button_3" value=" Home " onClick="index.cfm">
</td>
I have been told to do away with the images and make everything buttons, so I named the three buttons 1, 2, and 3 and sent everything to my action page, and did a cfif isdefined for each button, then did a cflocation url to pass to the apppropriate pages. That works ok.
But is there a way to do it without sending the first and third buttons to the action page, and only send the second one ?
This is what I have so far. The back button works, the second button still submits and validates, but I do not know how to code the third button, which should take me to the page index.cfm, when I click on it.
What is the proper syntax for this ? Thanks
<td align="center">
<INPUT TYPE="button" name="button_1" VALUE=" Back " onClick="history.go(-1)">
</td>
<td align="center">
<input type="button" name="button_2" value=" Upload File " onClick="validateForm(document.upload_form)">
</td>
<td align="center">
<input type="button" name="button_3" value=" Home " onClick="index.cfm">
</td>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/help-with-buttons/m-p/997348#M90725
Mar 03, 2008
Mar 03, 2008
Copy link to clipboard
Copied
onclick="window.location.href='index.cfm'
but... what happens if your user has js disabled?
replying heavily on client-side scripting is gonna get you in trouble...
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
but... what happens if your user has js disabled?
replying heavily on client-side scripting is gonna get you in trouble...
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
trojnfn
AUTHOR
Participant
,
/t5/coldfusion-discussions/help-with-buttons/m-p/997349#M90726
Mar 03, 2008
Mar 03, 2008
Copy link to clipboard
Copied
Thanks Azadi for your response.
If they do have js disabled, what would you suggest the best way to do this ? Back to my original method of sending all the buttons to the action page and then redirect with cflocation url ?
If they do have js disabled, what would you suggest the best way to do this ? Back to my original method of sending all the buttons to the action page and then redirect with cflocation url ?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/help-with-buttons/m-p/997352#M90729
Mar 04, 2008
Mar 04, 2008
Copy link to clipboard
Copied
quote:
Originally posted by: trojnfn
Thanks Azadi for your response.
If they do have js disabled, what would you suggest the best way to do this ? Back to my original method of sending all the buttons to the action page and then redirect with cflocation url ?
Alternatively, you could put your buttons inside anchor tags.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/help-with-buttons/m-p/997351#M90728
Mar 03, 2008
Mar 03, 2008
Copy link to clipboard
Copied
yep, that will guarantee the buttons (and other parts of your
form)
works as you intend it to.
as a rule, ALWAYS use server-side validation and processing. add in
client-side for added user experience and 'prettiness' - never rely on
client-side 100%.
hth
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
works as you intend it to.
as a rule, ALWAYS use server-side validation and processing. add in
client-side for added user experience and 'prettiness' - never rely on
client-side 100%.
hth
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
trojnfn
AUTHOR
Participant
,
/t5/coldfusion-discussions/help-with-buttons/m-p/997353#M90730
Mar 05, 2008
Mar 05, 2008
Copy link to clipboard
Copied
Hello Azadi,
I wanted to make my error messages consistent, like the popup when I use required=yes message, for cfinput.
For the error validation on the server side, I do something like this :
<cfif qry.recordcount eq "0">
<cflocation url="front_page.cfm?coming_from_screen="action_page">
</cfif>
Then back in the front page, I check for the url, then
<cfif coming_from_screen is "action_page">
<script>
alert("not records found">
</script>
</cfif>
This seems to work ok, since it is doing the edit/validation when submitted, then displaying the error message back on the front page.
The only problem is that it wipes out all the entries when the error message is displayed. Is there a way to keep what was already typed in, on the screen, when the error message is returned ?
I wanted to make my error messages consistent, like the popup when I use required=yes message, for cfinput.
For the error validation on the server side, I do something like this :
<cfif qry.recordcount eq "0">
<cflocation url="front_page.cfm?coming_from_screen="action_page">
</cfif>
Then back in the front page, I check for the url, then
<cfif coming_from_screen is "action_page">
<script>
alert("not records found">
</script>
</cfif>
This seems to work ok, since it is doing the edit/validation when submitted, then displaying the error message back on the front page.
The only problem is that it wipes out all the entries when the error message is displayed. Is there a way to keep what was already typed in, on the screen, when the error message is returned ?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/help-with-buttons/m-p/997354#M90731
Mar 05, 2008
Mar 05, 2008
Copy link to clipboard
Copied
the way i do it is:
a) <cfparam> each and every form var used on the page: if it's an
'insert/add' page - cfparam then to default values you need; on an
'update/edit' page cfparam them to values returned by the query taht
pulls the data to be edited from the db. it get a little bit trickier
with radio buttons/checkboxes/file uploads, but nothing too tricky.
b) each form field on the page has a value set to same name
#form.formfield#, i.e. <input type='text' name='fname'
value='#form.fname#'> - since i cfparam all of them, these FORM scope
vars are available to me even without submitting the form.
c) validate some form data on the client side using custom js and/or
cform's required attribute validation
d) validate all form data for value required and data format on the
server using cfif/cfelse and/or cfswitch/cfcase logic as necessary. i
usually set an err var (i.e. <cfset err = 0>) and errmsg var (i.e.
<cfset errmsg = "">) BEFORE the validation code block, then if a form
field does not validate i cfset err = 1 and errmsg = errmsg & "some text
about this error;<br />". then my db inserts/updates are inside a cfif
block which checks that err = 0.
e) in my from i have another cfif block that checks for err gt 0 and if
so cfoutputs #errmsg#. since all form fields have value set to their
value as described in b) above, all data posted by user is preserved in
the form. with file upload fields i usually do file upload only if
server-side form data validation succeeds; a user has to re-select a
file if form does not validate which is not too much of an
inconvenience, especially if you remind the user in your error message
to re-select the file...
now, the above is not a perfect solution, and in other cases may be an
overkill. this is just something i do. i could have forgotten to mention
something since it is pretty late here and i am rather tired. if i do
remember it tomorrow i will post more...
hth
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
a) <cfparam> each and every form var used on the page: if it's an
'insert/add' page - cfparam then to default values you need; on an
'update/edit' page cfparam them to values returned by the query taht
pulls the data to be edited from the db. it get a little bit trickier
with radio buttons/checkboxes/file uploads, but nothing too tricky.
b) each form field on the page has a value set to same name
#form.formfield#, i.e. <input type='text' name='fname'
value='#form.fname#'> - since i cfparam all of them, these FORM scope
vars are available to me even without submitting the form.
c) validate some form data on the client side using custom js and/or
cform's required attribute validation
d) validate all form data for value required and data format on the
server using cfif/cfelse and/or cfswitch/cfcase logic as necessary. i
usually set an err var (i.e. <cfset err = 0>) and errmsg var (i.e.
<cfset errmsg = "">) BEFORE the validation code block, then if a form
field does not validate i cfset err = 1 and errmsg = errmsg & "some text
about this error;<br />". then my db inserts/updates are inside a cfif
block which checks that err = 0.
e) in my from i have another cfif block that checks for err gt 0 and if
so cfoutputs #errmsg#. since all form fields have value set to their
value as described in b) above, all data posted by user is preserved in
the form. with file upload fields i usually do file upload only if
server-side form data validation succeeds; a user has to re-select a
file if form does not validate which is not too much of an
inconvenience, especially if you remind the user in your error message
to re-select the file...
now, the above is not a perfect solution, and in other cases may be an
overkill. this is just something i do. i could have forgotten to mention
something since it is pretty late here and i am rather tired. if i do
remember it tomorrow i will post more...
hth
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/help-with-buttons/m-p/997350#M90727
Mar 03, 2008
Mar 03, 2008
Copy link to clipboard
Copied
That actually works.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/coldfusion-discussions/help-with-buttons/m-p/997355#M90732
Mar 05, 2008
Mar 05, 2008
Copy link to clipboard
Copied
Hi trojnfn,
Try this code <input type="button" name="button_3" value=" Home " onClick="location.href='index.cfm';">
instead of your following code
<input type="button" name="button_3" value=" Home " onClick="index.cfm">
Hope this will works for you.
Try this code <input type="button" name="button_3" value=" Home " onClick="location.href='index.cfm';">
instead of your following code
<input type="button" name="button_3" value=" Home " onClick="index.cfm">
Hope this will works for you.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
LATEST
/t5/coldfusion-discussions/help-with-buttons/m-p/997356#M90733
Mar 06, 2008
Mar 06, 2008
Copy link to clipboard
Copied
Do you have this sorted yet? If not PM me and i'll be happy
to help you out.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

