SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2009
    Posts
    159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    pop up message when you click submit

    Hi
    Ive this line of code, which is a send button, but I'm trying to get a pop up message once I press it saying "are you sure you want to send" but where ever I put it in it doesnt work

    Code:
    <td colspan="1" align="right"><input type="button" value="Send Invoices &raquo;" onclick="document.checkmail.submit();"></td>
    I've tried putting it here
    Code:
    <td colspan="1" align="right"><input type="button" value="Send Invoices &raquo;" onclick="document.checkmail.submit()(Are you sure you want to send these);"></td>

  2. #2
    SitePoint Addict
    Join Date
    Dec 2008
    Location
    Aberdeen, Scotland
    Posts
    379
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is a Javascript question rather than ColdFusion so for a better response you'd be better directing this here: http://www.sitepoint.com/forums/forumdisplay.php?f=15

    Alternatively do a Google as you'll find plenty of examples / tutorials of this kind of thing

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Please do not use inline HTML events. They muddy up your HTML code and make it harder to manage your scripting.

    Instead, place the script just before the </body> tag.

    Code html4strict:
    <script type="text/javascript" src="js/script.js"></script>
    </body>

    With the HTML code, you really should use an actual submit button, so that your page can work even when no scripting is available.

    Despite that though, all you need in the HTML code is to place an identifier on the form tag.

    Code html4strict:
    <form id="sendInvoice" method="..." action="...">

    In the js/script.js script, use this code to capture and work with the form's submit event.

    Code javascript:
    document.getElementById('sendInvoice').onsubmit = function () {
        return window.prompt('Are you sure you want to send these');
    }

    When the person chooses [Cancel] then false will be returned, which prevents the form from being submitted. When the person choose [OK] the form will be sent.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •