how to access the attribute of object in a function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maminx
    New Member
    • Jul 2008
    • 77

    how to access the attribute of object in a function

    hello all,,

    i have this function of javascript

    Code:
    function setObj() {
    
    var form = document.forms[0];		
    var td = document.createElement('td');
    var theInputHpp = document.createElement('input');
    theInputHpp.setAttribute('type', 'text');
    theInputHpp.setAttribute('name', 'items['+form.podcnourut.value+'][podnhpp]'); 
    theInputHpp.setAttribute('size', '20');
    theInputHpp.setAttribute('value', form.podnhpp.value);
    theInputHpp.setAttribute('align', 'right');
    theInputHpp.setAttribute('readOnly','true');
    theInputHpp.style.textAlign="right";
    td.appendChild(theInputHpp);
    row.appendChild(td);
    			
    var td = document.createElement('td');
    var theInputDisc = document.createElement('input');
    theInputDisc.setAttribute('type', 'text');
    theInputDisc.setAttribute('name', 'items['+form.podcnourut.value+'][podndisc]');
    theInputDisc.setAttribute('size', '5');		
    theInputDisc.setAttribute('value',form.podndisc.value);
    theInputDisc.setAttribute('readOnly','true');
    theInputDisc.style.textAlign="right";			
    td.appendChild(theInputDisc);
    row.appendChild(td);
    }
    i want to access / get the attribute of podnhpp object (
    Code:
    theInputHpp.setAttribute('name', 'items['+form.podcnourut.value+'][podnhpp]');
    ) in another function, can u tell me how??

    thanks..

    regards,
    maminx
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    I have split your post into its own thread. Please do not hijack others' threads.

    Moderator.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Try
      Code:
      theInputHpp.setAttribute('name', items[form.podcnourut.value][podnhpp]);

      Comment

      Working...