DHTMLX Docs & Samples Explorer

Button

Button is classic representative of control group and we've made a resolve to consider it individually.

The following attributes are available for the button:

  • name - the name of the button
  • type - sets the 'button' element
  • value - the text on the button
  • command - the action for the button
  • validate - a validation rule

Pretty often, developers face the following situation: the user clicks the button - some action is executed.
So lets make it out.

Add event to a button you can with the following codelines:

<div id="formObj" style="position: relative; width: 250px;"></div>
   ....
var myForm = new dhtmlXForm("formObj");
var myEvent = myForm.attachEvent(onButtonClick, function(){
                                alert("Hello,world!")
});

Where:

  • onButtonClick - the name of the event
  • function() - the event handler

And delete this event detachEvent() method helps.

myform.detachEvent(myEvent);