Open Side Menu Go to the Top

05-13-2011 , 08:31 AM
Quote:
Originally Posted by daveT
If you have any ideas, feel free to post them.
That's the other thing. The best way to ensure that you stay motivated is to have the project be something you would actually get some use out of. The only reason The Opener exists is because I got sick and tired of having 10 different shortcuts on my desktop and needing to click at least 4 of them to start a session. The ideas I have kicking around in the back of my head are ideas I'd want to work on. They are also not web-based, so they wouldn't really help here anyways.

Quote:
Originally Posted by Gullanian
Learning how to debug is great, not bs great, actually great if you learn how and it should only take 10-20 mins to learn in chrome.

Download chrome, open your page and press Ctrl+Shift+J

Click on the scripts tab, and find then line

Code:
var heart = document.getElementById("heart");
Click on the line number, a blue square should appear around it. This is a break point, which means when the code executes it will pause at this point. Now reload the page, and the page will 'hang' on that line. A small red arrow will appear letting you know where it is in the script.

Hold your mouse over the variables for a second and an info popup will come up showing you information about the variable.

It will be useful for you, because you should be able to learn information about the variables you've assigned and you can rule them out one by one as being the cause of the problem.
This. Stepping through code with a debugger might be the biggest programming skills everyone should have (after actually being able to program). Effective debugging is the only you can solve a bug when you run into it. "Well A doesn't work, lets try B, etc" is going to take a long time and will not be helpful if the bug is actually caused by another piece of the code. Being able to step through and see the state of all the variables shows you exactly what things look like and you can see why it's not what you think it should be. And from there you can figure out why it is not that way.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
HTML5/CSS3/advancedJavascript learning and programming logs
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
HTML5/CSS3/advancedJavascript learning and programming logs
05-13-2011 , 06:27 PM
There is no error. It's doing what it's supposed to do. You're rendering an image outside of the canvas by using <img...>. If you want to hide the image do this:

Code:
<img style="display: none;" id="heart" src="http://i218.photobucket.com/albums/cc208/davidtoomey/heart.jpg" width="33" height="33">
If you don't want to litter your html with hidden images then try following the mozilla documentation tutorial for the canvas:

https://developer.mozilla.org/en/Can...ages#drawImage
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-13-2011 , 08:30 PM
What the hell kind of code is this?

https://developer.mozilla.org/sample...drawimage.html

The mozDoc may be okay, but a) their codes go against every other code format I have seen on the web, and b) I can't understand a word of what it says. The explanations are horrible.

The issue is that everyone codes this stuff differently, and it's not like these differences are minor either.


Compare the mozDoc code:

Code:
function draw() {       var ctx = document.getElementById('canvas').getContext('2d');       var img = new Image();       img.src = 'images/backdrop.png';       img.onload = function(){         ctx.drawImage(img,0,0);         ctx.beginPath();         ctx.moveTo(30,96);         ctx.lineTo(70,66);         ctx.lineTo(103,76);         ctx.lineTo(170,15);         ctx.stroke();       }     }
....to the standards:

http://www.whatwg.org/specs/web-apps...d-textbaseline

Code:
function redraw() {    var canvas = document.getElementsByTagName('canvas')[0];    var context = canvas.getContext('2d');    context.clearRect(0, 0, canvas.width, canvas.height);    drawCheckbox(context, document.getElementById('showA'), 20, 40, true);    drawCheckbox(context, document.getElementById('showB'), 20, 60, true);    drawBase();    if (document.getElementById('showA').checked)      drawAs();    if (document.getElementById('showB').checked)      drawBs();  }  function processClick(event) {    var canvas = document.getElementsByTagName('canvas')[0];    var context = canvas.getContext('2d');
Although I see what mozDoc did to change things around, it is still very confusing to someone who isn't particularly strong at this (me). MozDoc seems to be written for professional programmers, and those who are vigilant to get to the standard code.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-13-2011 , 09:19 PM
The real issue is you're trying to run before you can crawl (no offense). The problem had nothing to do with the canvas, it was just basic html/css knowledge.

Their code is not less standard than anything else btw. Javascript is a tricky language because there's a LOT of idioms.

You can daisy chain methods by just appending them with a period.

This example might be more clear:

Open up Chrome's developer window and goto the console, then type this:
Code:
"   CrAzY FriKkEn JaVaScRiPt      ".trim().toLowerCase();
You'll see the result is:
Spoiler:
"crazy frikken javascript"


And the reason is:
Spoiler:
It's doing both trim (removing leading and trailing spaces) and toLowerCase (converting it to lower case) in 1 shot.

So in the mozilla example they are setting the context to 2d by chaining it on the same line as the canvas declaration. In reality it's doing the same thing as setting up 2 variables and setting the context of the canvas separately.


Edit:
I know nothing about the canvas but I did my best to comment on what it's doing.

Code:
function draw() {
  // This is explained in the 2nd spoil above.
  var ctx = document.getElementById('canvas').getContext('2d');

  // We're creating a new image object.
  var img = new Image();

  // Now we're setting the source of the image to the location of the image...
  // ...we don't have to litter our HTML markup with phantom images anymore.
  img.src = 'images/backdrop.png';

  // Now we're passing a function to the img.onload method. In JS it's pefectly...
  // ...fine to pass a function as a value. 'onload' sounds like an event to me.
  // It's probably safe to say that when onload is triggered, the function is...
  // ...being executed.
  img.onload = function(){
    // We already know this, it's the location of where the image is being set in the canvas.
    ctx.drawImage(img,0,0);

    // Starting to draw some type of line, we're telling it to start the path.
    ctx.beginPath();

    // Then start at a specific coordinate.
    ctx.moveTo(30,96);

    // Then draw the 3 lines at specific coordinates (look at the graph, it's 3 lines).
    ctx.lineTo(70,66);
    ctx.lineTo(103,76);
    ctx.lineTo(170,15);

    // Drawing the line itself as a stroke. I assume you could make it dotted, set a color / different size, and so on.
    ctx.stroke();
  }
}

Last edited by Shoe Lace; 05-13-2011 at 09:34 PM.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-13-2011 , 10:50 PM
Quote:
The real issue is you're trying to run before you can crawl (no offense). The problem had nothing to do with the canvas, it was just basic html/css knowledge.
I totally agree. I just don't know where to dive in.

I mean, the free resources basically begins and ends at creating a pop-up then inserting something into prompt to say "hello davet" in a pop-up window.

But after that, the rest is same-ol' same-ol' and there isn't much in the way of showing how to build anything of use, so... create a project idea, implement it, and hope I don't tear my hair out before the week is out.

I guess I have to buy a good js book....
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-13-2011 , 11:14 PM
The tutorials you're reading are just client side javascript examples written by random tards most of the time. If you were watching poker coaching videos, for all you know the videos you're watching might be conducted by NL2 players who are losing 9BB/100.

The language itself isn't forced to be ran from your browser. It's a full fledged language. You're not limited to just doing alerts, document.writes and other browser specific actions.

If you don't feel like buying a book then your best is this:
https://developer.mozilla.org/en/JavaScript/Guide

Don't let your previous experiences with the moz docs sway you into thinking it's not good. The above link is pretty much the best general knowledge free javascript guide on the internet.

If you feel like buying a book, I would recommend this one:
http://oreilly.com/catalog/9780596805531 (released last month)

I'm on chapter 9 (the book is 1000 pages) and my previous experience with JS has been "I hack stuff together to make it work". I've learned a tremendous amount from this book so far and even without reading any other JS books I'll bet that a better one does not exist.

Last edited by Shoe Lace; 05-13-2011 at 11:20 PM.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-13-2011 , 11:32 PM
I was going to buy that one last year, but stopped programming for a few months. I saw that one was just released and I am drooling over the thought of it right now.

I've read a few javascript books, and to say the least, they have all been abysmal. I doubt that there is a better book than that one either.

After reading about 50% of that book, would someone be able to say, create a calculator? I mean, not one that is type-in, but one with press-buttons, emulating a real calculator?

Last edited by daveT; 05-13-2011 at 11:41 PM.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-13-2011 , 11:44 PM
I'm 100% convinced you don't need a CSS or HTML book though. There's no real programming involved, you're just declaring a bunch of different things.

All you need is a reference of what's available to declare and some experience under your belt to get a very solid understanding of it. Read the references first, then go looking around for examples if you want a kick start.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 12:00 AM
Wow, I learned more from that book in the first free pages they show than I learned in months of studying the resources available on the internet.

But...

There is an error on one of the codes.

I agree that there shouldn't be any need for an HTML/CSS book. The resources are good enough that you can figure out what you need on your own, plus the documentation is in plain enough English that there is no reason to clarify it.

Regardless, I can't imagine there is any future in creating CSS pianos.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 12:25 AM
Here is a tutorial on canvas. I don't know how good it is, but it seems fairly thorough.

http://www.html5canvastutorials.com/...-introduction/
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 12:32 AM
Another good JS book is JavaScript: The good parts by Douglas Crockford. He's a bit preachy at times, but it's a great book. It's a short read, but it's super dense. I'm reading through it now, and then planning on reading Pro JavaScript Design Patterns

http://www.amazon.com/JavaScript-Des.../dp/159059908X
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 12:58 AM
Here is a bunch of Crockford videos and small articles by him.

I watched the video on the history of development. It was quite eye-opening. The second part started up okay then went over my head.

http://javascript.crockford.com/
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 01:01 AM
I think that the real thing is that HTML/CSS is really just about presenting information. But the interesting part about the web is the information being presented and how that is built into some system that provides some functionality. Developing a good intuitive user interface is an important piece of any customer facing software, but without the business logic behind it, there isn't much motivation. This would be akin to learning Java, but only learning and using Swing.

You mentioned a calculator. That sounds like a nice small project that you could do and has some real functionality behind it. Try to make a simple 4 function calculator in HTML and you can use all Javascript for the calculations. First worry about making it 100% functional, then you can play with the CSS and make it look nice.

And if you want, you can transition that into a second phase. Instead of Javascript, use a form and a simple Python, PHP or Ruby back-end to handle the HTML post and generate the new page state based on the calculation associated with the pressed button.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 01:26 AM
Okay, fine: calculator starting in a few minutes, but first, have to go to the store.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 03:26 AM
Wowsers: calculator is way harder than one would think. This code is wretched beyond all repair, and it doesn't really work, unless a calculator simply displays one 1:

Just cover your eyes and ignore this one. Only here for documentation purposes:

Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">

<style type="text/css">

div{
width: 100px;
height: 20px;
border-style: solid;
border-color: blue;
}

</style>


<script type="text/javascript">

function writeOne() {
 document.getElementById('display').innerHTML = 1;
}
function startOne() {
 document.getElementById('one').onclick = writeOne;
}

function writeTwo() {
 document.getElementById('display').innerHTML = 2;
}
function startTwo() {
 document.getElementById('two').onclick = writeTwo;
}

function writeThree() {
 document.getElementById('display').innerHTML = 3;
}
function startThree() {
 document.getElementById('three').onclick = writeThree;
}

function writeFour() {
 document.getElementById('display').innerHTML = 4;
}
function startFour() {
 document.getElementById('four').onclick = writeFour;
}

function writeFive() {
 document.getElementById('display').innerHTML = 5;
}
function startFive() {
 document.getElementById('five').onclick = writeFive;
}

function writeSix() {
 document.getElementById('display').innerHTML = 6;
}
function startSix() {
 document.getElementById('six').onclick = writeSix;
}

function writeSeven() {
 document.getElementById('display').innerHTML = 7;
}
function startSeven() {
 document.getElementById('seven').onclick = writeSeven;
}

function writeEight() {
 document.getElementById('display').innerHTML = 8;
}
function startEight() {
 document.getElementById('eight').onclick = writeEight;
}

function writeNine() {
 document.getElementById('display').innerHTML = 9;
}
function startNine() {
 document.getElementById('nine').onclick = writeNine;
}

window.onload = startOne;
</script>
</head>
<body>

<div><span id="display"></span></div>

<button id="one">1</button>
<button id="two">2</button>
<button id="three">3</button>
<button id="four">4</button>
<button id="five">5</button>
<button id="six">6</button>
<button id="seven">7</button>
<button id="eight">8</button>
<button id="nine">9</button>
<button id="add">+</button>
<button id="subtract">-</button>
<button id="multiply">x</button>
<button id="divide">/</button>
<button id="equals">=</button>
    
</body>
</html>
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 08:33 AM
Not a bad start. The first thing that jumps out at me is the repeated code. Repeated code is bad because if later you have to change X, you have to remember everywhere you do X.

Instead, I wrote two helper functions:
Code:
function write(value) {
 document.getElementById('display').innerHTML = value;
}
function setOnClick(id, func) {
 document.getElementById(id).onclick = func;
}
This means all the write methods translate into:
Code:
function writeOne() {
 write(1);
}
The bug in your code was because you were only running startOne onLoad, so none of the other buttons had callbacks.

Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">

<style type="text/css">

div
{
width: 100px;
height: 20px;
border-style: solid;
border-color: blue;
}

</style>


<script type="text/javascript">

function write(value) {
 document.getElementById('display').innerHTML = value;
}

function writeOne() {
 write(1);
}

function writeTwo() {
 write(2);
}

function writeThree() {
 write(3);
}

function writeFour() {
 write(4);
}

function writeFive() {
 write(5);
}

function writeSix() {
 write(6);
}

function writeSeven() {
 write(7);
}

function writeEight() {
 write(8);
}

function writeNine() {
 write(9);
}

function setOnClick(id, func) {
 document.getElementById(id).onclick = func;
}

function init() {
  setOnClick('one', writeOne);
  setOnClick('two', writeTwo);
  setOnClick('three', writeThree);
  setOnClick('four', writeFour);
  setOnClick('five', writeFive);
  setOnClick('six', writeSix);
  setOnClick('seven', writeSeven);
  setOnClick('eight', writeEight);
  setOnClick('nine', writeNine);
}

window.onload = init;
</script>
</head>
  <body>
    <div><span id="display"></span></div>
    
    <button id="one">1</button>
    <button id="two">2</button>
    <button id="three">3</button>
    <button id="four">4</button>
    <button id="five">5</button>
    <button id="six">6</button>
    <button id="seven">7</button>
    <button id="eight">8</button>
    <button id="nine">9</button>
    <button id="add">+</button>
    <button id="subtract">-</button>
    <button id="multiply">x</button>
    <button id="divide">/</button>
    <button id="equals">=</button>
  </body>
</html>
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 01:12 PM
Quote:
Originally Posted by Shoe Lace
If you feel like buying a book, I would recommend this one:
http://oreilly.com/catalog/9780596805531 (released last month)

I'm on chapter 9 (the book is 1000 pages) and my previous experience with JS has been "I hack stuff together to make it work". I've learned a tremendous amount from this book so far and even without reading any other JS books I'll bet that a better one does not exist.
This book is bound to be absolutely brilliant. 100% recommended.

I have the Third edition, from back in 1998. It was my first "programming language" book, and it's superb. Obv loads of now defunct information in there like Netscape 4 vs IE4 differences in DOM and how to use JS to make a consistent interface to both, DHTML etc. but no doubt such things are updated to current status quo.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 02:17 PM
I haven't even gotten to the browser-specific chapters yet which is roughly half the book in itself. The first half of the book just gets you used to JS in general and what you can do with it as a language.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 02:19 PM
IMO, you should never have to worry about browser differences in JS. There's no reason to be writing raw javascript - jQuery, or another framework, handles those differences for you, and they are fast enough that you lose very little performance by adopting one.

And most importantly - the code is easier and faster to write.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 02:59 PM
When I mentioned browser-specific I meant just working with client side JS in general. I haven't read those chapters yet but I'm pretty sure there's more content in there than battling cross browser compatibility issues.

I think if you just dove into jquery without really understanding how JS works and how the DOM is setup you'll wind up being just another hack job coder. That might be good enough to get things done but it's going to be ugly most likely.

At the very least you'll need to understand anon functions, callbacks, closures, and get used to writing asynchronous code since the browser is basically just 1 big event loop.

Btw the calculator is missing the number zero.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 03:09 PM
Not much like jQuery existed back when my 3rd edition was published But really, the book, subtitled "a definitive guide", would be inappropriate to just say "use such and such library and don't worry what it's doing". It teaches you the underlying skills needed to create something like jQuery - or at least did in 1998. Now it can be argued these may not be relevant skills to many of today's developers, but for the purpose of education i think learning to create and understand the entirety of a language >>> learning to use a certain library. And someone has to write these libraries in the first place. jQuery developers obviously need to pay attention to browser differences in JS.

Timely posts from other thread today:
Quote:
Originally Posted by Gullanian
Quote:
Originally Posted by daveT
Yeah, I meant Ruby.

I think it was diebitter who said this: learning jQuery before mastering javascript is like reading Shakespeare before learning English.

I sort of agree with that one.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 03:37 PM
There's only a limited amount of time to learn a given language. All that JS frameworks do is take Javascript from what is a useful but nearly impossible to use language and make it standardized & much simpler to code. You still need to understand the underlying concepts, but it takes away a lot of unnecessary typing and fiddling with browser differences.

Quote:
At the very least you'll need to understand anon functions, callbacks, closures, and get used to writing asynchronous code since the browser is basically just 1 big event loop.
If you don't understand these things, you can't really write JQuery.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 05:48 PM
Quote:
Originally Posted by TheIrishThug
Not a bad start. The first thing that jumps out at me is the repeated code. Repeated code is bad because if later you have to change X, you have to remember everywhere you do X.

Instead, I wrote two helper functions:
Code:
function write(value) {
 document.getElementById('display').innerHTML = value;
}
function setOnClick(id, func) {
 document.getElementById(id).onclick = func;
}
This means all the write methods translate into:
Code:
function writeOne() {
 write(1);
}
The bug in your code was because you were only running startOne onLoad, so none of the other buttons had callbacks.

Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">

<style type="text/css">

div
{
width: 100px;
height: 20px;
border-style: solid;
border-color: blue;
}

</style>


<script type="text/javascript">

function write(value) {
 document.getElementById('display').innerHTML = value;
}

function writeOne() {
 write(1);
}

function writeTwo() {
 write(2);
}

function writeThree() {
 write(3);
}

function writeFour() {
 write(4);
}

function writeFive() {
 write(5);
}

function writeSix() {
 write(6);
}

function writeSeven() {
 write(7);
}

function writeEight() {
 write(8);
}

function writeNine() {
 write(9);
}

function setOnClick(id, func) {
 document.getElementById(id).onclick = func;
}

function init() {
  setOnClick('one', writeOne);
  setOnClick('two', writeTwo);
  setOnClick('three', writeThree);
  setOnClick('four', writeFour);
  setOnClick('five', writeFive);
  setOnClick('six', writeSix);
  setOnClick('seven', writeSeven);
  setOnClick('eight', writeEight);
  setOnClick('nine', writeNine);
}

window.onload = init;
</script>
</head>
  <body>
    <div><span id="display"></span></div>
    
    <button id="one">1</button>
    <button id="two">2</button>
    <button id="three">3</button>
    <button id="four">4</button>
    <button id="five">5</button>
    <button id="six">6</button>
    <button id="seven">7</button>
    <button id="eight">8</button>
    <button id="nine">9</button>
    <button id="add">+</button>
    <button id="subtract">-</button>
    <button id="multiply">x</button>
    <button id="divide">/</button>
    <button id="equals">=</button>
  </body>
</html>
I feel filthy for looking at this, but while I was laying awake until the wee hours of this morning, I was thinking of something like this.

I knew why the "bug" existed. I actually tried to do:

window.onload=startOne;
window.onload=startTwo;

As you probably already know, one no longer worked and only two worked, so I figured that I had to create a single function including all of the codes, though my solution probably wouldn't work. I am going to go ahead and create the code and see what happens, post it here and cry.

Quote:
Originally Posted by Shoe Lace

Btw the calculator is missing the number zero.
Good idea.

It's also missing a clear and clear all button.

-----------------

fwiw, that js book has a section dedicated to jQuery.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 07:13 PM
Quote:
Originally Posted by daveT
Here is a tutorial on canvas. I don't know how good it is, but it seems fairly thorough.

http://www.html5canvastutorials.com/...-introduction/
This tutorial is perfect for morons like me:


Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">

<script type="text/javascript">

window.onload = function(){
    var canvas = document.getElementById("theCanvas");
    var ctx = canvas.getContext("2d");
    
    ctx.beginPath();
    ctx.moveTo(50, 250);
    ctx.lineTo(200, 250);
    ctx.lineWidth=10;
    ctx.strokeStyle="blue";
    ctx.stroke();
    
    ctx.beginPath();
    ctx.moveTo(50, 250);
    ctx.lineTo(50, 150);
    ctx.lineWidth=10;
    ctx.strokeStyle="green";
    ctx.stroke();

    ctx.beginPath();
    ctx.moveTo(50, 150);
    ctx.lineTo(200, 150);
    ctx.lineWidth=10;
    ctx.strokeStyle="yellow";
    ctx.stroke();
    
    ctx.beginPath();
    ctx.moveTo(200, 150);
    ctx.lineTo(200, 250);
    ctx.lineWidth=10;
    ctx.strokeStyle="red";
    ctx.stroke();
    
    ctx.beginPath();
    ctx.moveTo(25, 175);
    ctx.lineTo(100, 100);
    ctx.lineWidth=10;
    ctx.strokeStyle="black";
    ctx.lineCap="round";
    ctx.stroke();
    
    ctx.beginPath();
    ctx.moveTo(100, 100);
    ctx.lineTo(225, 165);
    ctx.lineWidth=10;
    ctx.strokeStyle="black";
    ctx.lineCap="round";
    ctx.stroke();
    
};

</script>

</head>
<body>

<canvas id="theCanvas" width="300" height="300"></canvas>

</body>
</html>
HTML5/CSS3/advancedJavascript learning and programming logs Quote
05-14-2011 , 07:25 PM
This was sort of what I was thinking about this morning. Very strange that all the numbers present "9" in the display:

The solution I would create to counteract this is a bunch of if statements, but man, that would get ugly quickly.

Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">

<style type="text/css">

div{
width: 100px;
height: 20px;
border-style: solid;
border-color: blue;
}

</style>


<script type="text/javascript">

function write() {
document.getElementById('display').innerHTML = 1;
document.getElementById('display').innerHTML = 2;
document.getElementById('display').innerHTML = 3; 
document.getElementById('display').innerHTML = 4; 
document.getElementById('display').innerHTML = 5;
document.getElementById('display').innerHTML = 6;
document.getElementById('display').innerHTML = 7;
document.getElementById('display').innerHTML = 8;
document.getElementById('display').innerHTML = 9;
}

window.onload = function start() {
document.getElementById('one').onclick = write;
document.getElementById('two').onclick = write;
document.getElementById('three').onclick = write;
document.getElementById('four').onclick = write;
document.getElementById('five').onclick = write;
document.getElementById('six').onclick = write;
document.getElementById('seven').onclick = write;
document.getElementById('eight').onclick = write;
document.getElementById('nine').onclick = write;
}


</script>
</head>
<body>

<div><span id="display"></span></div>

<button id="one">1</button>
<button id="two">2</button>
<button id="three">3</button>
<button id="four">4</button>
<button id="five">5</button>
<button id="six">6</button>
<button id="seven">7</button>
<button id="eight">8</button>
<button id="nine">9</button>
<button id="zero">0</button>
<button id="add">+</button>
<button id="subtract">-</button>
<button id="multiply">x</button>
<button id="divide">/</button>
<button id="equals">=</button>
<button id="clear">clear</button>
<button id="clear all">clear all</button>

</body>
</html>
HTML5/CSS3/advancedJavascript learning and programming logs Quote
HTML5/CSS3/advancedJavascript learning and programming logs
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
HTML5/CSS3/advancedJavascript learning and programming logs

      
m