[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

DOM/DHTML to pass vars 2x one function builds another call  using JAVASCRIPT

Posted on 2007-10-12
2
Medium Priority
?
415 Views
Last Modified: 2013-11-19
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.parentNode.parentNode);
      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</span></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].innerHTML+'" default="'+tdObjs[i].innerHTML+'">';
           else
            tdObjs[i].innerHTML = '<input type="hidden" name="'+arrColumnNames[i-2]+'"     id="input-'+arrColumnNames[i-2]+'" value="'+tdObjs[i].innerHTML+'" default="'+tdObjs[i].innerHTML+'">';
      return false;
}

function saveRecord(obj,a,b) {

      //           A      TD         TR    
      var trObj = obj.parentNode.parentNode;
      //              TR     TBODY      TABLE
      var tableObj = trObj.parentNode.parentNode;
      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),'string');
      if (response.substr(0,2) != "id") alert(response);
      else {
            trObj.id = response.substr(3);
            stopEditing(trObj,false);
      }
}









0
Comment
Question by:madpuppy
2 Comments
 
LVL 23

Accepted Solution

by:
basicinstinct earned 1000 total points
ID: 20070020
may i ask, what type of object is stored in the variables a and b?

the problem is here: onclick="saveRecord(this,a,b);"
you are just saying that onclick is this string: "saveRecord(this,a,b);"  'a' and 'b' are just part of the string, they have nothing to do with the variables you passed into the function...

i'd have to do some experiments, but you could start by trying this:

onclick="saveRecord(this,' + a + ',' + b' + ');"
0
 

Author Comment

by:madpuppy
ID: 20070031
Thank you that was it I thought I could get off easy on all those wee '

Thanks tons
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question