javascript - Confused on ordering of function calls and debugging -
i trying debug function call in jsp program , confused on ordering of how things worked. using netbeans. when run project in debug mode, goes '$("#searcheft").mouseup(function ()' function , trace through of it. 'searcheft' button using access servlet. when process page , click 'searcheft' button, hits function call based on getting right alert doesn't trace in debug. why doing that? first call of function on load setting check when user mouseclick?
this function outside of '$(document).ready(function ()' @ top , function call after button declaration in jsp.
edit: here jsp code:
<head> <script> $(document).ready(function () { $(function () { $("#cmdcreationdate").datepicker({ dateformat: "yy-mm-dd" }); }); }) ; window.onbeforeunload = confirmexit; function confirmexit() { alert("alert-- leaving page."); } function numbersonly(myfield, e, dec) { //function check numeric values entered var key; var keychar; if (window.event) key = window.event.keycode; else if (e) key = e.which; else return true; keychar = string.fromcharcode(key); // control keys if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27)) return true; // numbers else if ((("0123456789").indexof(keychar) > -1)) return true; // decimal point jump else if (dec && (keychar == ".")) { myfield.form.elements[dec].focus(); return false; } else return false; } </script> </head> <body> <header> <?audit suppress oracle.ide.xml.validation-error?> <div class="floatl appttl">sams - eft schedule number search/update screen</div> <div id="navwrap"> <nav class="floatr"> <ul> <li> <a href="#">home</a> </li> <li> <a href="#">search</a> </li> <li> <a href="#">help</a> </li> <li> <a href="#">help</a> </li> </ul> </nav> </div> <div class="clear"></div> </header> <main class="mainwrapper"> <form id="formid" method="post" action="eftscreen?action=searcheft" > <div class="commandcontainer"> <div id="divbox"> <h1 class="formttl">please enter schedule number/contract year or either schedule status/creation date value</h1> <label class="labelttl">schedule number</label> <label class="labelttl3">contract year</label> <label class="labelttl3">status</label> <label class="labelttl">creation date</label> <br/> <input id="cmdschedulenumber" name="cmdschedulenumber" type="number" class="textsmall" maxlength="5" value="${schedulenum}" onkeypress="return numbersonly(this, event)"/> <input id="cmdcontractyear" name="cmdcontractyear" type="number" class="textsmall" maxlength="4" value="${contractyear}" onkeypress="return numbersonly(this, event)"/> <select size="1" id="cmdschedstatus" name="cmdschedstatus" class="combosmall"> <c:foreach items="${statuslist}" var="current"> <option value="${current}" <c:if test="${current == status}"> selected="selected"</c:if> >${current}</option> </c:foreach> </select> <input id="cmdcreationdate" name="cmdcreationdate" type="text" class="textsmall" value="${creationdate}" maxlength="10"/> <br/> <button id="searcheft" class="btn smbtn">search</button> </div> <div id="divbutton"> <button id="searchmefts" type="submit" formaction="eftscreen?action=searchmefts&screen=maineft" class="btn midbtn">update schedule status</button> <button id="clearmenu" type="submit" formaction="eftscreen?action=clearmenu" class="btn midbtn space">return menu</button> </div> <div id="clear"></div> </div> <article class="divboxdet"> <fmt:formatnumber var="trdettotal" value="${detresults.gettotal_amount()}" pattern="$##,###,##0.00"/> <label class="labelttldet floatl"> schedule number <input id="txtschedulenumber" type="number" class="textdet" value="${detresults.getschedule_number()}" readonly/> </label> <label class="labelttldet floatl"> contract year <input id="txtcontractyear" type="number" class="textdet" value="${detresults.geteft_contract_year()}" readonly/> </label> <label class="labelttldet floatl"> date created <input id="txtcreationdate" type="text" class="textdet" value="${detresults.getcreation_date()}" readonly/> </label> <div class="clear"></div> <br/> <br/> <label class="labelttldet floatl"> num of records <input id="txtnumrecords" type="number" class="textdet" value="${detresults.getnum_of_pay_records()}" readonly/> </label> <label class="labelttldet floatl"> status <br/> <input id="txtstatus" type="text" class="textdet" value="${detresults.getstatus()}" maxlength="2"/> </label> <label class="labelttldet floatl"> status date <input id="txtstatusdate" type="text" class="textdet" value="${detresults.getstatus_date()}" maxlength="10"/> </label> <div class="clear"></div> <br/> <br/> <label class="labelttldet floatl"> schedule total <input id="txtscheduletotal" type="text" class="textdet" value="${trdettotal}" readonly/> </label> <label class="labelttldet floatl"> schedule post date <input id="txtpostdate" type="text" class="textdet" value="${detresults.getschedule_post_date()}" maxlength="10"/> </label> <label class="labelttldet floatl"> reel number <input id="txtreelnumber" type="text" class="textdet" value="${detresults.getreel_number()}" maxlength="8"/> </label> <div class="clear"></div> <br/> <br/> <button id="pullmeftd" class="btn largebtn space floatl">update schedule payment status</button> <script> $("#searcheft").mouseup(function () { var cmd_sched_number = $('#cmdschedulenumber').val(); var schedlen = cmd_sched_number.length; //var cmd_contract_year = document.getelementbyid("cmdcontractyear").value; var cmd_contract_year = $('#cmdcontractyear').val(); var yearlen = cmd_contract_year.length; //var cmd_status = document.getelementbyid("cmdschedstatus").value; var cmd_status = $('#cmdschedstatus').val(); var statstr = cmd_status.replace(/\s/g, ""); var statlen = statstr.length; //var cmd_creation_date = document.getelementbyid("cmdcreationdate").value; var cmd_creation_date = $('#cmdcreationdate').val(); var createlen = cmd_creation_date.length; if ((schedlen > 0 && yearlen === 0) || (schedlen === 0 && yearlen > 0)) { alert("schedule number , eft contract year must both populated"); } ; if ((statlen === 0) && (createlen === 0) && (schedlen === 0) && (yearlen === 0)) { var r = confirm("are sure want pull eft schedule numbers?"); if (r === false) { alert("please enter information in of command line fields"); return false; } else { $('#formid').submit(); } } ; }); $("#pullmefts").mouseup(function () { var det_sched_number = $('#txtschedulenumber').val(); var detschedlen = det_sched_number.length; //var cmd_contract_year = document.getelementbyid("cmdcontractyear").value; var det_contract_year = $('#txtcontractyear').val(); var detyearlen = det.length; var det_status = $('#txtstatus').val(); if (detschedlen > 0) { alert("schedule number not found. please investigate"); } ; if ( holdstatus.matches("rp") || holdstatus.matches("vp") || holdstatus.matches("cp") ) { alert("user can update schedule number in np status"); } }); </script> </article> </form> </main> </body>
thanks
the line:
$("#searcheft").mouseup(function ()
is function call sets mouseup
handler; not mouseup handler itself.
if want break inside mouseup handler need set breakpoint somewhere inside handler function itself, e.g.,
// first executable line of mouseup handler var cmd_sched_number = $('#cmdschedulenumber').val();
unrelated, break handler function much smaller pieces, roughly:
function getformdata() { return { number: $('#cmdschedulenumber').val().trim(), year: $('#cmdcontractyear').val().trim(), status: $('#cmdschedstatus').val().replace(/\s/g, '').trim(), date: $('#cmdcreationdate').val().trim() }; } function invalidnumberandyear(formdata) { return ((formdata.number !== '') && (formdata.year === '')) || ((formdata.year !== '') && (formdata.number === '')); } function ispullall(formdata) { return formdata.number === '' && formdata.year === '' && formdata.status === '' && formdata.date === ''; } function searcheftmouseup(e) { e.preventdefault(); var formdata = getformdata(); if (invalidnumberandyear(formdata)) { alert('schedule number , eft contract year must both populated'); return; } if (ispullall(formdata)) { if (confirm('are sure want pull eft schedule numbers?')) { $('#formid').submit(); } else { alert('please enter information in of command line fields'); } } } $('#searcheft').on('mouseup', searcheftmouseup);
this allows small stuff thought easily, , begins reveal validation needs, , suggests shape remaining code.
(most of which, btw, not relevant question–it's post minimum amount necessary people understand issue :)
Comments
Post a Comment