Buttons OnClick Event not firing when it causes a textboxes onChange event to fire first
Posted
by user48408
on Stack Overflow
See other posts from Stack Overflow
or by user48408
Published on 2009-10-01T11:20:27Z
Indexed on
2010/04/13
12:02 UTC
Read the original article
Hit count: 367
JavaScript
|javascript-events
I have a few textboxes and button to save their values on a webpage. The onchange event of the textboxes fires some js which adds the changed text to a js array. The ok button when clicked flushes this to the database via a webservice. This works fine except when the onchange event is caused by clicking the ok button. In this scenario the onchange of the textboxes still fires but the onClick event of the button does not. Any ideas?
textboxes look something like
<input name="ctrlJPView$tbcTabContainer$Details$JP_Details_Address2Text" type="text" value="test"
id="ctrlJPView_tbcTabContainer_Details_JP_Details_Address2Text" onchange="addSaveDetails('Jobs###' + document.getElementById('ctrlJPView_tbcTabContainer_Details_JP_Details_Address2Text').value + ');" style="font-size:8pt;Left:110px;Top:29px;Width:420px;Height:13px;Position:absolute;" />
My save button
<input type="button" name="ctrlJPView$btnOk" value="OK" onclick="saveAmendments();refreshJobGrids();return false;__doPostBack('ctrlJPView$btnOk','')" id="ctrlJPView_btnOk" class="ControlText" style="width:60px;" />
UPDATE: I guess this comes down to one of two things. 1) Something is happening before the onClick of the button gets called to surpress that call such as an inadvertent return false; or 2) the onClick event isn't firing at all. Now I've rem'd out everything actually inside the functions that are being called beforehand but the problem persists. But if i remove the call altogether it works (???)
© Stack Overflow or respective owner