When I select a row in the grid and then click on the update button from the form that I attached this way
myForm.attachEvent(“onButtonClick”, function (idd) {
The event UpdateContact(); run one time. But, if I click on another row in the grid and then click on the update button updateContact() runs 2 times. Etc etc. etc. each time I click on a row and then click update.
Is this because the myForm.attachEvent is inside the contactsGrid.attachEvent??
What to do??
This is the code that gets duplicated:
myForm.attachEvent(“onButtonClick”, function (idd) {
UpdateContact()
})
This is the entire procedures code:
contactsGrid.attachEvent(“onRowSelect”, function (id, ind) {
fName = contactsGrid.cells(id, 0).getValue();
eMail = contactsGrid.cells(id, 1).getValue();
intField = contactsGrid.cells(id, 2).getValue();
idval = contactsGrid.getSelectedRowId();
selDate = contactsGrid.cells(id, 3).getValue();
myForm.setItemValue("name", fName);
myForm.setItemValue("email", eMail);
myFormIntegerVal.setItemValue("intField", intField);
//set the date in the calendar
var d = new Date(selDate);
var yyyy = d.getFullYear();
var mm = d.getMonth() + 1;
var dd = d.getDate();
if (mm < 10) mm = '0' + mm;
var curDate = yyyy + '-' + mm + '-' + dd;
if (curDate != "NaN-NaN-NaN") {
calendarMain.setDate(curDate);
}
statusBarMain.setText(fName);
idVal = fName + eMail + intField;
varText = "<P>" + fName + "'s email address is " + eMail + "</P> <P>The integer value is: " + intField + "</P>";
editor.setContent(varText)
myForm.attachEvent("onButtonClick", function (idd) {
UpdateContact()
})
// myFormIntegerVal.attachEvent(“onButtonClick”, function (iddd) {
// UpdateContact();
// })
// myFormExtra.attachEvent(“onButtonClick”, function (idddd) {
// UpdateContact();
// })
})
})