A page that interacts

Where are we?

You know how to create basic HTML pages. The tags you’ve learned are at the heart of Web work.

In this chapter, you’ll start learning about interactivity. This means that users can click on things, drag things, type into things.

A good example is the lesson tree. You know what happens when you click on a +. This isn’t just a frill; it’s useful. You can drill down into the books and chapters, without having to look at everything.

Some effects are there just because. Like the way the tabs at the top of the page jump. I’m a geek, and proud of it!

Most interactivity is done with JavaScript. Writing interactive JavaScript used to be hard work. It’s gotten a lot easier over the past few years. Now beginners can add cool effects to their pages, make slideshows, write games, and other stuff.

Before we get too fancy, you need to learn a few basics. That’s what this chapter is about.

Programming is scary!

This chapter is about programming.

CC
CC

Are you crazy? I can barely balance my check book! I hate all that math stuff!

Kieran
Kieran

Hey, calm down. Breathe, that’s it.

Many people think they can’t do it. But my 20 years of experience says you can learn programming, at least to the level that CoreDogs covers. Which, as programming goes, isn’t a lot.

Some things to remember.

First, how you learn matters. If I threw a bunch o’ tech at you all at once, of course you’d be confused. That’s natural.

Unfortunately, most tech experts don’t have strong teaching skills. They move too fast, cover too much, too quickly. Deep down, some experts think that programming isn’t hard, so learners shouldn’t need help.

They’re wrong. Programming is hard to learn, if you try to learn it from an unskilled teacher, or a poorly written book. Most people can do it. But teachers and authors need to understand how people learn, and respect learners’ experiences.

Let’s take it slowly. In fact, really slowly for someone as anxious as you are, CC. Baby steps.

This chapter is long. The reason? We go slowly. Baby step, baby step, baby step. That might bug you if you already know how to program. Please remember that others are learning this for the first time.

Second, find someone else to learn with. Not an expert, but someone who’s at your level, or a little ahead. If you and your buddy do need expert help, pick someone who is patient.

Third, I want to kill a myth. Programming is not about math. All those sines and cosines you learned to fear? You won’t see them here. No calculus, no factoring, no quadratics.

CC
CC

Really? Promise?

Kieran
Kieran

Yes, I promise. Pinkie swear. The most complicated thing is finding the area of a circle, and I’ll even give you the formula.

Tell me something, and be honest. Could you balance your checkbook, if you really wanted to?

CC
CC

Well, yes, you got me, I could. I can add and subtract. Even multiply and divide, on a good day.

Kieran
Kieran

Then you’re all set.

The most difficult thing about programming is breaking down a large problem into smaller ones, so you can work on each small one independently. This has nothing to do with math. People who write history books do the same thing. They take big events (e.g., the American Civil War), break them into parts (e.g., The US before the war, The first shot, The south’s initial success, ...), and write a chapter for each one.

Renata
Renata

You’ve spent a lot of time on CC’s anxiety.

Kieran
Kieran

Yes. You might not feel it, but she does, and it will get in the way of her learning. Learning is the goal, so anything that interferes should be dealt with.

Please be patient. The three of us are a team, going through CoreDogs together. Let’s respect each other’s struggles.

This chapter’s goals

By the end of this chapter, you should:

  • Know what JavaScript is, and how to include it on a page.
  • Be able to tie JavaScript code to an event, like a click.
  • Be able to write JavaScript to change things on a page.
  • Know how to ask users questions, and respond to their answers.

Let’s get started.

CC
CC

Come on CC, you can do it, girl.

Kieran
Kieran

Yes, you can. And I’ll hold your paw all the way.


How to...

Lessons

User login

Log in problems? Try here


Dogs