Skip to main content
Inspiring
March 3, 2008
Question

Help with buttons

  • March 3, 2008
  • 4 replies
  • 605 views
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>
    This topic has been closed for replies.

    4 replies

    Participant
    March 6, 2008
    Do you have this sorted yet? If not PM me and i'll be happy to help you out.
    Astonished_protector15C3
    Participating Frequently
    March 6, 2008
    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.
    Inspiring
    March 4, 2008
    That actually works.
    Inspiring
    March 3, 2008
    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/
    trojnfnAuthor
    Inspiring
    March 3, 2008
    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 ?
    Inspiring
    March 4, 2008
    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.