please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Button Element

Name

Button Element---a graphical pushbutton

Availability

Navigator 2.0, Internet Explorer 3.0; enhanced in Navigator 3.0

Synopsis

form.button_name
form.elements[i]

Properties

form

A read-only reference to the Form object that contains the Button.

name

A read-only String, set by the HTML NAME attribute, that specifies the name of the button.

type

A read-only string that specifies the type of this form element. For Button elements, it has the value "button". Available in Navigator 3.0 and later.

value

A read-only String property, specified by the HTML VALUE attribute, which specifies the value displayed in the Button element.

Methods

blur()

Remove keyboard focus from the button.

click()

Simulate a click on the button.

focus()

Give keyboard focus to the button.

Event Handlers

onblur()

Invoked when the button loses keyboard focus.

onclick()

Invoked when the button is clicked.

onfocus()

Invoked when the button is given keyboard focus.

HTML Syntax

A Button element is created with a standard HTML <INPUT> tag, with the addition of the onClick attribute:

<FORM>
    ...
  <INPUT
    TYPE="button"   specifies that this is a button
    VALUE="label" the text that is to appear within the button
    specifies the value property
    [ NAME="name" ]   a name that can later be used to refer to the button
    specifies the name property
    [ onClick="handler" ] JavaScript statements to be executed when the button
    is clicked
  >
    ...
</FORM>

Description

The Button element represents a graphical push button in a form within an HTML document. The value property contains the text that is displayed by the button. The name property is a name by which the button may be referred to. The onClick event handler is invoked when the user clicks on the button.

Usage

Use a Button element whenever you want to allow the user to trigger some action on your web page. You can sometimes use a Link object for the same purpose, but unless the desired action is to follow a hypertext link, a Button is a better choice than a Link, because it makes it more explicit to the user that there is something to be triggered.

Note that the Submit and Reset elements are types of Buttons that submit a form and reset a form's values. Often these default actions are sufficient for a form, and you do not need to create any other types of buttons.

Example

<FORM name="form1">
    <INPUT type="button"
        name="press_me_button"
        value="Press Me"
        onClick="name =index.html prompt('What is your name?',")"
    >
</FORM>

See Also

"Element", "Form", "Reset", "Submit"


Previous Home Next
Boolean.valueOf() Book Index Button.blur()

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/java/script/definitive/refp_20.htm, 8KB, , updated: 2019/10/14 15:00, local time: 2024/11/22 23:36,
TOP NEW HELP FIND: 
3.133.150.249:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/techref/language/java/script/definitive/refp_20.htm"> [Chapter 21] Reference: Button</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .