Welcome to Dream.In.Code
Getting Help is Easy!

Join 86,373 Programmers. There are 1,441 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

web development

 
Closed TopicStart new topic

web development, events handling

kokito
post 20 Mar, 2008 - 09:42 PM
Post #1


New D.I.C Head

*
Joined: 26 Feb, 2008
Posts: 6



Here is my question:
I want to add an erase feature to the following drawing program.

CODE

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



<html xmlns = "http://www.w3.org/1999/xhtml">
        <head>
    <title></title>
    <style type = "text/css">
    #canvas { width: 400px;
          border: 1px solid #999999;
          border-collapse: collapse }
    td      { width: 4px;
          height: 4px }
    th.key  { font-family: arial, helvetica, sans-serif;
          font-size: 12px;
          border-bottom: 1px solid #999999 }
    
    </style>
    <script type = "text/javascript">
    <!--
    
    function createCanvas ()
    {
        var side = 100;
        var tbody = document.getElementById( "tablebody" );

        for(var i =0; i < side; i++)
        {
            var row = document.createElement( "tr" );
    
            for(var j=0; j < side; j++)
            {
                var cell = document.createElement ( "td");
                cell.onmousemove = processMouseMove;
                row.appendChild( cell );
            }
            tbody.appendChild ( row );
        }
    }
    
    function processMouseMove( e )
    {
        if( !e )
            var e = window.event;
    
        if( e.ctrlKey )
            this.style.backgroundColor = "blue";
        if( e.shiftKey )
            this.style.backgroundColor = "red";
        if( e.altKey )
            this.style.backgroundColor = "white";
    }

    // -->
    </script>
    </head>
    <body onload = "createCanvas()">
        <table id = "canvas" class = "canvas"><tbody id = "tablebody">
        <tr><th class = "key" colspan = "100">Hold <tt>ctrl</tt>
        to draw blue. Hold <tt>shift</tt> to draw red. </th></tr>
        </tbody></table>
    </body>
</html>
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


spearfish
post 21 Mar, 2008 - 09:24 PM
Post #2


Monkey in Training

Group Icon
Joined: 10 Mar, 2008
Posts: 670

To erase all maybe reloading the canvas? To erase some letting the pencil be the color of the background?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

PsychoCoder
post 21 Mar, 2008 - 09:28 PM
Post #3


ToCode || !ToCode

Group Icon
Joined: 26 Jul, 2007
Posts: 5,858

kokito,

You have this same exact question in the JavaScript forum. Double posting isnt going to get you help any faster
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

no2pencil
post 22 Mar, 2008 - 06:45 PM
Post #4


DIC K-mart

Group Icon
Joined: 10 May, 2007
Posts: 3,322

1.) Please don't post web development topics in the web hosting forum
2.) Please don't double post
3.) code.gif

Thank you!
User is online!Profile CardPM
Go to the top of the page
+Quote Post

Closed TopicStart new topic
Time is now: 5/17/08 02:41AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month