Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Alert function to print not working

    Hi, sorry i know this has been covered time and time again but after hours of looking at previous coding examples i just couldn't figure out how to make mine work! ( ARG! ) so i have a button on my page that invokes a script to alert the user to ask if they wish to print... then i wish to redirect them to another page... ( i havnt bothered putting in my redirect yet as i havnt gotten the alert to pop-up in the first place )

    <script language="javascript">
    function Addnew()
    {if (confirm("if you would you like to Print the book information press ok, if not press cancel"))

    window.print();

    -(this is where i'll redirect)-

    }
    else{

    -(this is where i'll redirect)-

    }

    </script>

    ...
    (page's code)
    ...

    <input type="button" name="AddNew" value="Add New" onclick="Addnew()" >

    ------

    i just dont see what im doing wrong... Thanks in advance

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Something like this?
    PHP Code:
    <html>
    <
    head>
    <
    script type="text/javascript">
    function 
    ask()
    {
        var 
    choice confirm("if you would you like to Print the book information press ok, if not press cancel");
        if(
    choice)
        {
            
    alert("ok");
        }
        else
        {
            
    alert("cancel");
        }
    }

    </script>
    </head>
    <body>
    <form action="" method="">
    <input type="button" name="click" value="Print" onclick="ask();">
    </form>
    </body>
    </html> 

  • #3
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a crapload Brando -- sorry this took a while to respond, i only work on my coding mon -> fri @ school....


  •  

    Posting Permissions

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