SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Converting an anchor tag with Javascript to a form button

    How can I make a form button that is the equivalent of:

    <a href="http://myUrl.com" onClick="return(window.confirm('Are you sure?'));">Click here</a>


    I know it will be something like (no Javascript listed below):

    <input type='button' name='buttonName' value='Button Name' Javascript goes here... >


    Any help is greatly appreciated.

  2. #2
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just use a regular submit button and call your function through the form's onsubmit event. Returning true from the function will submit the form, returning false will not. Just be sure to specify the return when calling the function, as in onsubmit="return myFunction();", as well as setting the return value in the function.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •