Online Book Reader

Home Category

HTML, XHTML and CSS All-In-One for Dummies - Andy Harris [60]

By Root 1466 0
= “radio“

name = “radPrice“

id = “rad200“

value = “200“ />Way too much

name = “radPrice“

id = “rad5000“

value = “5000“

checked = “checked“ />You’ve got to be kidding.


Pressing Your Buttons

XHTML also comes with several types of buttons. You use these guys to make something actually happen. Generally, the user sets up some kind of input by typing in text boxes and then selecting from lists, options, or check boxes. Then, the user clicks a button to trigger a response. Figure 7-9 demonstrates four types of buttons.

The code for this button example is shown here:

“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

buttons.html

Button Demo

input-style buttons

value = “input type = button“ />

button tag buttons

Figure 7-9: XHTML supports several types of buttons.

Each button type is described in this section.


Making input-style buttons

The most common form of button is just another form of your old friend, the tag. If you set the input’s type attribute to “button”, you generate a basic button:

value = “input type = button” />

The ordinary Input button has a few key features:

♦ The input type is set to “button”. This makes an ordinary button.

♦ The value attribute sets the button’s caption. Change the value attribute to make a new caption. This button’s caption shows how the button was made: input type = “button”.

♦ This type of button doesn’t imply a link. Although the button appears to depress when it’s clicked, it doesn’t do anything. You have to write some JavaScript code to make it work.

♦ Later, you’ll add event-handling to the button. After you discover JavaScript in Book IV, you use a special attribute to connect the button to code.

♦ This type of button is for client-side programming. This type of code resides on the user’s computer. I discuss client-side programming with JavaScript in Book IV.

Building a Submit button

Submit buttons are usually used in server-side programming. In this form of programming, the code is on the Web server. In Book V, you use PHP to create server-side code. The tag is used to make a Submit button, too!

Although they look the same, the Submit button is different than the ordinary button in a couple subtle ways:

♦ The value attribute is optional. If you leave it out, the button displays Submit Query. Of course, you can change the value to anything you want, and this becomes the caption of the Submit button.

♦ Clicking it causes a link. This type of button is meant for server-side programming. When you click the button, all the information in the form is gathered and sent to some other page on the Web.

♦ Right now, it goes nowhere. When you set the form’s action attribute to null (“”), you told the Submit button to just reload the current page. When you figure out real server-side programming, you change the form’s action attribute to a program that works with the data.

♦ Submit buttons aren’t for client-side. Although you can attach an event to the Submit button (just like the regular Input button), the linking behavior often causes problems. Use regular Input buttons for client-side and Submit buttons for server-side.

It’s a do-over: The Reset button

Yet another form of the versatile tag creates

Return Main Page Previous Page Next Page

®Online Book Reader