Advertisement

10.12.2007 at 07:15PM PDT, ID: 22890929
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.8

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

Asked by madpuppy in JavaScript, Scripting Languages, Dynamic HTML (DHTML)

Tags: , , , ,

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);
      }
}









Start Free Trial
 
Loading Advertisement...
 
[+][-]10.12.2007 at 07:24PM PDT, ID: 20070020

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: JavaScript, Scripting Languages, Dynamic HTML (DHTML)
Tags: another, one, javascript, call, passing
Sign Up Now!
Solution Provided By: basicinstinct
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628