Message Thread: |
View All MessagesBack to WebFX |
Brian, Here's most of the code. You'll notice right away that there are references to other functions that I didn't include below. I have removed those functions without affecting this issue so I'm confident that they're irrelevant to this problem. If you want them, though, I'll send them. I just didn't want to overwhelm you with script or confuse the issue. I really appreciete your help. I doubt many people would take the time. Thanks. function udeSubmit(screenCode, parameters) { document.body.style.cursor = 'wait'; //replaceInvalidChars(); if(submitFlag == false){ //when submitFlag is true, we disable all submissions var doSubmit=true; try { doSubmit = onUDESubmit(); } catch (e) {} try{ if (doSubmit) {//this is where doSubmit is run - returns t/f submitFlag = true;//should prevent further submissions disableButtons();//disables all html buttons disableMenu();//disables menus at top // parameters is an ampersand-delimited set of key/value pairs doubleBrackets(); if(parameters){//place parameters into an array var pairs = parameters.split("&"); for( var i=0;i<pairs.length;i++){ var pos=pairs[i].indexOf('=');//returns location of the first occurance of '=' or -1 if there are none if(-1 == pos) continue;// error handling for bad value var fieldName=pairs[i].substring(0,pos); var fieldValue=pairs[i].substring(pos+1); addField('process', fieldName, 'hidden', fieldValue); } process.screenCode.value = screenCode; process.submit(); }else{ process.screenCode.value = screenCode; //alert('right before the submit: '+document.process.teleRecord0.value); process.submit(); } }else{ //when submit is cancelled, change cursor back to an arrow document.body.style.cursor = 'default'; } }catch(e){ document.body.style.cursor = 'default'; } }else{ document.body.style.cursor = 'default'; } }// end function function onUDESubmit(){ document.process.permanentStorageIn.value = document.process.permanentStorageIn0.value; // loop through all the form elements formObject = document.process; for (var i = 0; i < formObject.length; i++){ var formElement = formObject.elements[i]; if(formElement.type == "textarea"){ // need to remove tabs since they are errorneous characters on the green screen formElement.value = formElement.value.replace(/\t/ig, " "); if(!(checkTextArea(formElement))){ formElement.focus(); return false; } } } return true; } // =================================================================================== // Function...: checkTextArea // Description: takes a text area and checks its value against the predefined rows and // cols attributes. It will return true if the value does not exceed in // length the maximum size implied by the number of rows and columns. // Otherwise, it will return false with an alert message. // =================================================================================== function checkTextArea(textArea){ val = textArea.value + "\r"; cols = textArea.cols; rows = textArea.txtMaxRows; myRegEx = /\r/ig; rowCount = 0; var myArray = val.split(myRegEx); var rowCalc = 0; var debugStr = ""; for(var i=0; i < myArray.length; i++) { rowCalc = Math.ceil( ( (myArray[i].replace(/\f/gi,"").replace(/\r/gi,"").replace(/\n/gi,"").length) / cols) ); rowCount = rowCount + rowCalc; if(rowCalc == 0) { rowCount++; } // debugStr += "i: " + i + " "; // debugStr += "rowCalc: " + rowCalc + " "; // debugStr += "rowCount: " + rowCount + " "; // debugStr += "value: " + myArray[i] + " "; // debugStr += "<br/>\n"; } // document.write(debugStr); // alert("rowCount: " + rowCount); if(rowCount > rows) { alert('You have entered ' + rowCount + ' rows and have exceeded the maximum number of rows for this text area, which is ' +rows+'.\nPlease either reduce the size of your message or arrange it so that ' +'it fits on '+rows+' rows.'); return false; } return true; }// end function |