Javascript replace error on text area

Ciberblackjam

New Member
I have researched this to death and not having much luck. Javascript replace method is working on the first 4 textareas, but on the 5th I get the error, "Object doesn't support this property or method". I can't figure out why.HTML:\[code\]<textarea id="freeText1" cols="48" rows="4"></textarea><textarea id="freeText2" cols="48" rows="4" ></textarea><textarea id="freeText3" cols="48" rows="4" ></textarea><textarea id="freeText4" cols="48" rows="4" ></textarea><textarea id="freeText5" cols="48" rows="4" ></textarea>\[/code\]Javacript:\[code\]function cleanText(t){var str = t.replace(/['":;]/g,'');return str;}function collectdata() {var data = http://stackoverflow.com/questions/14494695/[ //My Details {"dbField" : "myUserID" , "dbFieldDesc" : "Officer ID" , "dbFieldType" : "text" , "dbValue" : $("#myUserId").val() }, { "dbField" : "myName", "dbFieldDesc" : "Officer Name" , "dbFieldType" : "text" , "dbValue" : $("#myName").val() }, { "dbField" : "myTeam" , "dbFieldType" : "text" , "dbValue" : $("#myTeam").val() }, { "dbField" : "myStream" , "dbFieldType" : "text" , "dbValue" : $("#myBL").val() }, { "dbField" : "mySite" , "dbFieldType" : "text" , "dbValue" : $("#mySite").val() }, //CSO Details { "dbField" : "csoName" , "dbFieldType" : "text" , "dbValue" : $("#tags").val() }, { "dbField" : "csoFlag" , "dbFieldType" : "bit" , "dbValue" : $("#csoSpecific").is(':checked') }, { "dbField" : "csoSite" , "dbFieldType" : "text" , "dbValue" : $("#csoSite").val() }, { "dbField" : "csoLine" , "dbFieldType" : "text" , "dbValue" : $("#csoBL").val() }, { "dbField" : "csoTeam" , "dbFieldType" : "text" , "dbValue" : $("#csoTeam").val() }, { "dbField" : "origCsoSiteFlag" , "dbFieldType" : "bit" , "dbValue" : $("#originatingsite").is(':checked') }, { "dbField" : "origCsoLineFlag" , "dbFieldType" : "bit" , "dbValue" : $("#originatingbusiness").is(':checked') }, { "dbField" : "origCsoSite" , "dbFieldType" : "text" , "dbValue" : $("#csoSite2").val() }, { "dbField" : "origCsoLine" , "dbFieldType" : "text" , "dbValue" : $("#csoBL2").val() }, { "dbField" : "csoTL" , "dbFieldType" : "text" , "dbValue" : csoTL }, //Feedback Details { "dbField" : "csid" , "dbFieldType" : "bigint" , "dbValue" : $("#csid").val() }, { "dbField" : "escalationSource" , "dbFieldType" : "text" , "dbValue" : $("#escalationSource").val() }, { "dbField" : "date1" , "dbFieldType" : "dateval" , "dbValue" : $("#date1").val() }, { "dbField" : "date2" , "dbFieldType" : "dateval" , "dbValue" : $("#date2").val() }, { "dbField" : "decisionChanged" , "dbFieldType" : "text" , "dbValue" : $("#decisionchanged").val() }, //Categories { "dbField" : "assessment" , "dbFieldType" : "text" , "dbValue" : getChkVal("AssessmentChk") }, { "dbField" : "collection" , "dbFieldType" : "text" , "dbValue" : getChkVal("CollectionChk") }, { "dbField" : "coaReasons" , "dbFieldType" : "text" , "dbValue" : getChkVal("COAReasonsChk") }, { "dbField" : "businessProcesses" , "dbFieldType" : "text" , "dbValue" : getChkVal("busproChk") }, { "dbField" : "disbursement" , "dbFieldType" : "text" , "dbValue" : getChkVal("disbChk") }, { "dbField" : "enforcement" , "dbFieldType" : "text" , "dbValue" : getChkVal("enfChk") }, { "dbField" : "legalPolicy" , "dbFieldType" : "text" , "dbValue" : getChkVal("legpolChk") }, { "dbField" : "review" , "dbFieldType" : "text" , "dbValue" : getChkVal("reviewChk") }, { "dbField" : "serviceChannel" , "dbFieldType" : "text" , "dbValue" : getChkVal("servchanChk") }, { "dbField" : "serviceQuality" , "dbFieldType" : "text" , "dbValue" : getChkVal("servqalChk") }, { "dbField" : "collectionAction" , "dbFieldType" : "text" , "dbValue" : getChkVal("collChk") }, //Outcomes { "dbField" : "outcomeDecision" , "dbFieldType" : "text" , "dbValue" : $("#outcome").val() }, { "dbField" : "freeText1" , "dbFieldType" : "text" , "dbValue" : cleanText( $("#freeText1").val() ) }, { "dbField" : "freeText2" , "dbFieldType" : "text" , "dbValue" : cleanText( $("#freeText2").val() ) }, { "dbField" : "freeText3" , "dbFieldType" : "text" , "dbValue" : cleanText( $("#freeText3").val() ) }, { "dbField" : "freeText4" , "dbFieldType" : "text" , "dbValue" : cleanText( $("#freeText4").val() ) }, { "dbField" : "potentialDevelopmentNeed" , "dbFieldType" : "text" , "dbValue" : cleanText( $("#freeText5").val() ) }, //Development { "dbField" : "proceeduralInstructions" , "dbFieldType" : "text" , "dbValue" : $("#PIschosen").val() }, { "dbField" : "ServicePrinciples" , "dbFieldType" : "text" , "dbValue" : getChkVal("serviceprinciples") }];var t = "DataCapture_QSRCRFeedback" // t = tablevar n = "("; // n = field namesvar v = "("; // v = field valuesvar r = data.length - 1; // r = number of records (-1 accounts for index starting at 0)var d = ""; // d = current data value//Loop through each record in the data set and build 2 strings - one for field names, and one for values.$.each(data, function(i, item) { //build a string of field names n += data.dbField; //convert null values to blank "" d = data.dbValue; if(d == null) {d = ""}; switch(data.dbFieldType) { case "bit": if(d == true) {v += "1"} else {v += "0"}; break; case "bigint": if(d == 0) {d="''"}; v += d; break; case "datetime": d!=''? v += "'" + (d.getMonth() + 1) + "-" + d.getDate() + "-" + d.getFullYear() + "'" : v += ''; break; default: var str = cleanText(d); v += "'" + str + "'"; break; } //if not the last record, separate each string iteration with a comma if( i != r ) { n += ", "; v += ", "; }});n += ")";v += ")";sql = "INSERT INTO [" + t + "] " + n + " ";sql += "VALUES " + v;runSQL(sql);}\[/code\]No matter what I do, it always throws an error when I run the replace on the value of freeText5. The value of freeText5 can be empty, or any text, and same error. Everything is identical, I don't understand why this is occuring.Any help would be awesome! Thanks! :)
 
Back
Top