www.webdeveloper.com
Results 1 to 6 of 6

Thread: [RESOLVED] Cannot get alert() to work

  1. #1
    Join Date
    Jan 2009
    Posts
    20

    resolved [RESOLVED] Cannot get alert() to work

    I want to use a button with an onClick(), but I am missing something in the syntax. For testing, I am using the alert() function. Can you point out what I am missing?

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Test</title>
    </head>
    <body>
    <input name="btnOrder" type="button" value="Test" onClick="alert(\'Hello\'")>
    </body>
    </html>

    Feeling a little dumb,

    Todd

  2. #2
    Join Date
    Mar 2010
    Posts
    2,803
    maybe try:

    Code:
     
    <input name="btnOrder" type="button" value="Test" onClick="alert('Hello');" />

  3. #3
    Join Date
    Jan 2009
    Posts
    20
    That works! However, when I go to the next step, open a window, my code is not working.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Test</title>
    <script language="javascript" type="text/javascript">
    <!--
    function openWindow(theURL,winName,features) {
    window.open(theURL,winName,features);
    }
    //-->
    </script>
    </head>
    <body>
    <input name="btnOrder" type="button" value="Order"
    onClick="openWindow('hawk_order.php','ordWindow','toolbar=no,status=yes,scrollbars=no,resizable=no'" />
    </body>
    </html>

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Missing closing bracket
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <script type="text/javascript">
    function openWindow(theURL,winName,features) {
    window.open(theURL,winName,features);
    }
    </script>
    </head>
    <body>
    <input name="btnOrder" type="button" value="Order"
     onclick="openWindow('hawk_order.php','ordWindow','toolbar=no,status=yes,scrollbars=no,resizable=no');">
    </body>
    </html>
    At least 98% of internet users' DNA is identical to that of chimpanzees

  5. #5
    Join Date
    Jan 2009
    Posts
    20
    Fang - First, thank you! Second, my apologies. I consider this site to be a valuable resource, so I kick myself when I take "bandwidth" with dumb mistakes.
    Todd

  6. #6
    Join Date
    Jan 2009
    Posts
    20
    Fang -
    Could you check my new post where I took the code that you helped me get working and placed it into a php page. There it does not work. Baffled!!

    Todd

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles