Dual Function Button | JavaScriptSource

Dual Function Button

JavaScriptSource Staff Apr 13, 2007

General

This script allows one button to have two or more functions


Notes

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: dualFunctionButton.js


Head

Paste this code into the HEAD section of your HTML document.


Body

Paste this code into the BODY section of your HTML document


Leave a Response

(3 comments)

Well, it says it allows you to use one button to perform two or more functions. This is only one example. If you have another, go ahead and [a href="http://javascript.internet.com/contribute/"]submit it to us[/a].

Lee May 25, 2007

1- it should be fine to have an introduction to this function, such as what it can be used for (pratical example in real life)[br /]2- the code should be more generic: using forms[0].elements[0] is too specific and will not work if the button is not inserted as the first element of the first form of the page. Passing the button reference to the javascript function would be at least a first step to genericity.

G.Jacquet Apr 23, 2007

Nice one. But you are checking for the value of an variable i to switch between functions. If there were more buttons, It will be tedious to maintain/refernce all the values . Can modify the code in a betterway. so that this can be used for not only buttons but for other controls also. [p]Nice Idea yaar. Please take my comments as positive..[p]Thanks & Regards[br /]Kumar S

Kumar S Apr 15, 2007