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

Join 107,670 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,029 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



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


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


Monkey in Training

Group Icon
Joined: 10 Mar, 2008
Posts: 704



Dream Kudos: 200
My Contributions


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

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


DIC.Rules == true;

Group Icon
Joined: 26 Jul, 2007
Posts: 7,143



Thanked 50 times

Dream Kudos: 7700

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, GDI

My Contributions


kokito,

You have this same exact question in the JavaScript forum. Double posting isnt going to get you help any faster
User is online!Profile CardPM

Go to the top of the page

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


Wet D.I.C.

Group Icon
Joined: 10 May, 2007
Posts: 4,840



Thanked 27 times

Dream Kudos: 2325

Expert In: Goofing Off

My Contributions


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

Closed TopicStart new topic
Time is now: 8/29/08 11:10PM

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