View Single Post
Old 09-09-2012, 02:45 AM   PM User | #1
Red Dragon
New to the CF scene

 
Join Date: Jun 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Red Dragon is an unknown quantity at this point
trouble with addEventListener

I'm trying to gets this code to work so that when you click submit it will send whats in the textbox to the php script but its not sending the post request.
Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                            <script type="text/javascript" src="test2.js"></script>
                            <link rel="stylesheet" type="text/css" href="test4.css" id="linkPage" />
                            <title>
                                    test site
                            </title>
           
                    </head>
                    <body>
            <div id="yourdivname">
            </div>
            <form action="" method="post">
                    <input type="text" id="mytextbox" />
                    <input type="submit" id="submit1" value="Send" />
            </form>
            <SCRIPT>
        var submit1 = document.getElementById('submit1');
                submit1.addEventListener("submit",function sendmessage (e) {
                var message = form.mytextbox.value;
                xhr.open("POST", "send.php");
                xhr.send(JSON.stringify(message));
                e.preventDefault()
                    },false);
            </SCRIPT>
     
    </html>

Last edited by Red Dragon; 09-09-2012 at 05:25 AM..
Red Dragon is offline   Reply With Quote