Web Programming Step by Step
Discussion Section 5: Order-It
Basic JavaScript

section idea/code by Sylvia Tashev and Stefanie Hatcher

This section is about using JavaScript to create an interactive UI.

Buggy JavaScript Code:

The following pages have mistakes that cause their JavaScript code not to work properly. Look at the pages, find the bug(s), and correct the problems.

  1. buggy page #1 (JavaScript)
  2. buggy page #2 (JavaScript)
  3. buggy page #3 (JavaScript)
  4. buggy page #4 (JavaScript)

The following links may help you in the debugging process:

Order-It:

Today we'll write a page that lets us perform various manipulations on the text in a text area. Here is the page (click the image to run our sample solution, written by Sylvia Tashev and Stefanie Hatcher): (solution JS code orderit.js)

expected form output

The HTML and CSS are already written, but we must add JavaScript code to make the UI respond when the user clicks the buttons. Start from the following skeleton:

Add the following behavior to the buttons:

Recall that you can retrieve the JavaScript "DOM" object for a given HTML element with the document.getElementById function. Recall that an array has a length field and methods such as: concat, join, pop, push, reverse, shift, slice, sort, splice, unshift

If you finish all of that behavior, consider adding a button to change the capitalization of lines, such as capitalizing/lowercasing entire lines or converting lines to AlTeRnAtInG cAsE.

Valid XHTML 1.1 Valid CSS!