In my web site: www.sanestrategies.net, I'm experiencing anomalous behavior. I'm including here, the html page in question: show.html, and a subset of the javascript file: funcs2.js (below; it won't let me upload the file). You can see the full javascript file at http://sanestrategies.net/funcs.js. The path to try is: From Find/View, choose a Browse option, then select one of the strategies presented. This brings up show.html. Click on the Submit button without entering anything anywhere on the page, especially do not check the Vote Box. Problem #1: the web page will return with a "Thank you" message displaying in the shSuccess span: <span id="shSuccess" class="shSuccess"></span>, and the number of votes displayed will be incremented by one. Clicking on the Submit button calls up shFormGet.js. This first tests the form for any errors with testShowPost.js. I return true from this when all is empty. This function tests to see if the Vote Box (votebox) has been checked, setting a hidden element to the same value. The problem occurs in shClrForm.js. When it tests the checkbox, it finds that it has been checked and sets the variable bool4Vote=true. Then, since this variable is true, it fills the shSuccess span mentioned above with the "Thank you" message. Since I haven't checked the Vote Box, it should not display this message and increment the vote. I've set break points where it tests for bool4Vote=true in shClrForm.js and it doesn't stop. Neither does it stop in the same function when it fills the shSuccess span. When I set a conditional break point, for when the attributes are modified, i.e., the span is filled, it stops, but shows line 139 in show.html which is: </tr>. Problem #2 When I set the break point to where the checkbox being checked in shClrForm.js, it checks the box by itself and then shows it being checked in the watch point. By "itself", I mean every browser debugger I've used: Chrome's "inspect element", Firefox's "inspect element", and Firefox's Firebug. I am stumped as to this behavior, both problems, and would greatly appreciate any assistance. Thank you in advance. Baruch funcs2.js /* Directory getFormValues(fobj) called by: adFormGet(), shFormGet(), vuFormGet() jsSanitize() called by: getFormValues() postDataAjax(url, parameters) called by: adFormGet(), shFormGet(), vuFormGet() shClrForm(fobj) called by: shFormGet() shDataOutput() called by: shRefreshCommTable(), shSetup() shFormGet(frm, url) called by: show.html: button spsubmitbutton onclick() shRefreshCommTable() called by: shClrForm() testShowPost() called by: shFormGet() */ function getFormValues(fobj) { var str = ""; for(var i = 0;i < fobj.elements.length;i++) { switch(fobj.elements.type) { case "text": str += fobj.elements.name + "=" + jsSanitize(fobj.elements.value) + "&"; break; case "textarea": str += fobj.elements.name + "=" + jsSanitize(fobj.elements.value) + "&"; break; case "radio": // why use this 1/29/14? if (fobj.elements.checked==true) { str += fobj.elements.name + "=" + jsSanitize(fobj.elements.value) + "&"; } // if fobj.elements.checked break; case "hidden": str += fobj.elements.name + "=" + jsSanitize(fobj.elements.value) + "&"; break; case "select-one": // drop down list, can select only one str += fobj.elements.name + "=" + fobj.elements.options[fobj.elements.selectedIndex].value + "&"; break; } // switch } // for str = str.substr(0,(str.length - 1)); return str; } // getFormValues() function jsSanitize(theData) // combines encodeURIComponent() w/apostrophe replacement { var tempData=theData.replace(/(\r\n|\n\r|\n|\r)/g," "); tempData=tempData.trim(); tempData=encodeURIComponent(tempData); tempData=tempData.replace(/!/g, "%21"); tempData=tempData.replace(/\(/g, "%28"); tempData=tempData.replace(/\)/g, "%29"); tempData=tempData.replace(/\~/g, "%7E"); tempData=tempData.replace(/\'/g, "%27"); tempData=tempData.replace(/\</g, "%3C"); tempData=tempData.replace(/\>/g, "%3E"); tempData=tempData.replace(/\@/g, "%40"); theData=tempData; return theData; } // jsSanitize() function postDataAjax(url, parameters, synch) { var ajRO = ajOpen(); ajRO.timeout=10000; ajRnreadystatechange = function() { if(ajRO.readyState > 0 && ajRO.readyState < 4) { document.getElementById(jsAJmsg).innerHTML=loadingmessage; } // if(ajRO.readyState > 0 && ajRO.readyState < 4) if (ajRO.readyState == 4) { if (ajRO.status == 200) { document.getElementById(jsAJmsg).innerHTML=ajRO.responseText; } // if (ajRO.status == 200) else { alert('XmlHttpRequest error!'); } // else if (ajRO.status == 200) } // if (ajRO.readyState == 4) } // function() ajRpen("POST", url, synch); ajRO.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); ajRO.send(parameters); } // postDataAjax() function shClrForm(fobj) { var thnk4Comment = "Thank you for your comment!"; var thnk4Vote = "Thank you for your vote!"; var tnk4Both = "Thank you for your comment and your vote!"; var bool4Comment = false; var bool4Vote = false; var bool4Both = false; for (var i = 0;i < fobj.elements.length;i++) { switch(fobj.elements.type) { case "text": if (fobj.elements.value!="") {bool4Comment=true;} fobj.elements.value=""; break; case "textarea": if (fobj.elements.value!="") {bool4Comment=true;} fobj.elements.value=""; break; // case "hidden": // commented out B: showLeave() checks for hidden: shvotebox // fobj.elements.value=""; // break; case "checkbox": if (fobj.elements[i].checked=true) {bool4Vote=true;} fobj.elements[i].value="no"; fobj.elements[i].checked=false; break; } // switch } // for if (bool4Comment && bool4Vote) {bool4Both=true;} if (bool4Both) {document.getElementById("shSuccess").innerHTML=tnk4Both;} else if (bool4Comment) {document.getElementById("shSuccess").innerHTML=thnk4Comment;} else if (bool4Vote) {document.getElementById("shSuccess").innerHTML=thnk4Vote;} if (bool4Both || bool4Comment) {shRefreshCommTable();} if (bool4Both || bool4Vote) {shRefreshShVotes();} } // shClrForm() function shDataOutput(comName,comM) { if (nCResult > 0) { var sptName=comName.split(","); var sptCom=comM.split(","); var newData=""; var tblVar = "<table border='0' width='100%' id='CommentTable' style='table-layout: fixed'>"; var cGroupVar = "<colgroup><col width='50px'><col width='100px'></colgroup><tr><td colspan='1'>Commenter</td><td colspan='1'>Comment</td></tr>"; for (i = 0; i < nCResult; i++) {newData += "<tr><td>" + sptName[i] + "</td><td>" + sptCom[i] + "</td>";} document.getElementById("shComentData").innerHTML = tblVar + cGroupVar + newData + "</table>"; } // if (nCResult > 0) } // shDataOutput() function shFormGet(frm, url) { var frmOK = testShowPost(); if (!frmOK) {return false;} var poststr = getFormValues(frm); postDataAjax(url, poststr, true); shClrForm(frm); } // shFormGet() function shRefreshCommTable() { var tab = document.getElementById("CommentTable"); var elems = tab.getElementsByTagName("tr"); // REMEMBER: 2 tr per row var len = elems.length; var newCommenter = ""; var newCmment = ""; //this puts all of the current table data into 2 arrays for (i = 1; i < len; i++) // 0 row is header data { newCommenter += (document.getElementById("CommentTable").rows[i].cells[0].innerHTML) + ","; newCmment += (document.getElementById("CommentTable").rows[i].cells[1].innerHTML) + ","; } // for ( i = 1; i < len; i++ ) newCommenter += document.getElementById("shcmterName").value; newCmment += document.getElementById("shthecomment").value; nCResult = i; shDataOutput(newCommenter,newCmment); } // shRefreshCommTable() function testShowPost() { var shCName = document.getElementById("cmterName").value; var shCEm = document.getElementById("cmterEmail").value; var shComm = document.getElementById("thecomment").value; var lshCName = shCName.length; var lshCEm = shCEm.length; var lshComm = shComm.length; var nErr = "Please enter your name"; var eErr = "Please enter your email address"; var cErr = "Please enter your comment"; document.getElementById("shcmterName").value = shCName; document.getElementById("shcmterEmail").value = shCEm; document.getElementById("shthecomment").value = shComm; document.getElementById("shvotebox").value = ((document.getElementById("votebox").checked)? "yes" : "no"); if (lshCName==0 && lshCEm==0 && lshComm==0) // ALL empty { document.getElementById("shNameErr").innerHTML=''; document.getElementById("shEmailErr").innerHTML=''; document.getElementById("shCommentErr").innerHTML=''; return true; // 8/8/14: was: false; } if (lshCName>0 && lshCEm>0 && lshComm>0) // ALL filled { document.getElementById("shNameErr").innerHTML=''; document.getElementById("shEmailErr").innerHTML=''; document.getElementById("shCommentErr").innerHTML=''; return true; } if (lshCName>0 && lshCEm>0 && lshComm==0) // name & email filled, comment missing { document.getElementById("shNameErr").innerHTML=''; document.getElementById("shEmailErr").innerHTML=''; document.getElementById("shCommentErr").innerHTML=cErr; return false; } if (lshCName>0 && lshCEm==0 && lshComm>0) // name & comment filled, email missing { document.getElementById("shNameErr").innerHTML=''; document.getElementById("shEmailErr").innerHTML=eErr; document.getElementById("shCommentErr").innerHTML=''; return false; } if (lshCName>0 && lshCEm==0 && lshComm==0) // name filled, email & comment missing { document.getElementById("shNameErr").innerHTML=''; document.getElementById("shEmailErr").innerHTML=eErr; document.getElementById("shCommentErr").innerHTML=cErr; return false; } if (lshCName==0 && lshCEm>0 && lshComm==0) // email filled, name & comment missing { document.getElementById("shNameErr").innerHTML=nErr; document.getElementById("shEmailErr").innerHTML=''; document.getElementById("shCommentErr").innerHTML=cErr; return false; } if (lshCName==0 && lshCEm>0 && lshComm>0) // email & comment filled, name missing { document.getElementById("shNameErr").innerHTML=nErr; document.getElementById("shEmailErr").innerHTML=''; document.getElementById("shCommentErr").innerHTML=''; return false; } if (lshCName==0 && lshCEm==0 && lshComm>0) // comment filled, name & email missing { document.getElementById("shNameErr").innerHTML=nErr; document.getElementById("shEmailErr").innerHTML=eErr; document.getElementById("shCommentErr").innerHTML=''; return false; } else { document.getElementById("shNameErr").innerHTML=''; document.getElementById("shEmailErr").innerHTML=''; document.getElementById("shCommentErr").innerHTML=''; } return true; } // testShowPost()[/i][/i][/i][/i][/i][/i][/i]
So what you're saying is can a professional JavaScript developer fix my problem for free. In London alone a decent JavaScript developer cost £350+ per day. How about hiring one rather than trying to get freebies.
I've been trying to find paid support; this forum was suggested. Haven't you got something more constructive to do than to diss me?
A good place to go for something like this is stackoverflow.com where they enjoy helping people for free.