I have created several programmatic buttons but cannot get their respective onClick functions to fire.
In the example below, the onClick works fine if the button is created declaratively in the markup, but it returns "this.OnClick is not a function" when the button is created programmatically in javascript.
This works...
<button dojotype="dijit.form.Button"
id="Clear_Form"
jsid="Clear_Form"
label="Clear Form"
onclick="clearForm()">
</button>
id="Clear_Form"
jsid="Clear_Form"
label="Clear Form"
onclick="clearForm()">
</button>
But for some reason this does not...
var doc = document;
var div_buttons = doc.createElement("div");
var btn_clearForm = doc.createElement("span");
var parmform = doc.getElementById("parmform");
div_buttons.appendChild(btn_clearForm);
parmform.appendChild(div_buttons);
var clearForm = new dijit.form.Button({
id:"Clear_Form",
jsId:"Clear_Form",
label:"Clear Form",
onClick: clearForm
},dojo.byId(btn_clearForm));I have tried each of the following:
onClick: clearForm, onClick: clearForm() onclick: "clearForm" onClick: "clearForm()"
...but in each case when the button is clicked it simply returns "this.onClick is not a function". Any ideas on where I've gone wrong would be appreciated.

A quick glance.. is
A quick glance.. is clearForm() a function declared somewhere? Looks like you are re-using that variable and assigning a widget to it.