Hello I have a startEditing function that has to "build" a href call to another function and pass 2 vars (a,b)
Those a,b are fine this startEditing function ( I can print them out to see them there), but I get an "a is undefined" when I click the new built href calling saverecord function I just built. what am I doing wrong?
BTW this all works perfectly except for when I add this passing of these vars - I need them for the save.
function startEditing(trObj,a,b) {
var arrColumnNames = getColumnNames(trObj.paren
tNode.pare
ntNode);
var tdObjs = trObj.getElementsByTagName
('TD');
tdObjs[0].innerHTML = '<a class="save" href="#" onclick="saveRecord(this,a
,b);" title="Save this record"><span>Save</span><
/a>';
tdObjs[1].innerHTML = '<a class="cancel" href="#" onclick="cancelEditRecord(
this);" title="Cancel editing"><span>Cancel</spa
n></a>';
for (var i=2;i<tdObjs.length;i++)
if(i==3)
tdObjs[i].innerHTML = '<input type="text" name="'+arrColumnNames[i-2
]+'" id="input-'+arrColumnNames
[i-2]+'" value="'+tdObjs[i].innerHT
ML+'" default="'+tdObjs[i].inner
HTML+'">';
else
tdObjs[i].innerHTML = '<input type="hidden" name="'+arrColumnNames[i-2
]+'" id="input-'+arrColumnNames
[i-2]+'" value="'+tdObjs[i].innerHT
ML+'" default="'+tdObjs[i].inner
HTML+'">';
return false;
}
function saveRecord(obj,a,b) {
// A TD TR
var trObj = obj.parentNode.parentNode;
// TR TBODY TABLE
var tableObj = trObj.parentNode.parentNod
e;
var inputObjs = trObj.getElementsByTagName
('INPUT');
var rowId = trObj.id;
var url = tableObj.id;
// Call SET/ADD method to save record to the database
if ((rowId) && (rowId != ""))
url += '.cfc?method=set&rowId=' + rowId;
else
url += '.cfc?method=add';
for (var i=0;i<inputObjs.length;i++
)
url += '&' + inputObjs[i].name + '=' + inputObjs[i].value;
// set the owner and level vars passed in
url += '&ownerid=' + b;
url += '&levelid=' + a;
var response = wddxGetElement(httpRequest
(url),'str
ing');
if (response.substr(0,2) != "id") alert(response);
else {
trObj.id = response.substr(3);
stopEditing(trObj,false);
}
}
Start Free Trial