• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

Make inner.html, more compatible???

I have this code(partial):
----------------------------

function updateBar(change) {
   ofTotal += change;
   if(ofTotal <= 0){
         var pbarw = 0;
   }else{
            var pbarw = Math.round(barWidth * ofTotal);
            if (pbarw > barWidth){pbarw = barWidth;}
   }
   document.getElementById('percentNumeric').innerHTML = Math.round(pbarw *100/barWidth);//need to be more compatible
   getObj(progressBarId).style.width = pbarw;
}

function getObj(objid) {
   if (document.getElementById(objid)) {
      return(document.getElementById(objid));
   } else if (document.getElementsByName(objid)[0]) {
      return(document.getElementsByName(objid)[0]);
   } else if (document.all[objid]) {
      return(document.all[objid]);
   } else if (document.layers[objid]) {
      return(document.layers[objid]);
   } else {
      return false;
   }
}

//-->
</script>
</head>
<body onload="setBar();updateBar(0);">

<div id="totalBar" style="border:1px solid black;"><div id="progressBar"></div></div>

<div id="percentNumeric">The value is:</div>

</body>

---------------------------------
How do I make this line more browser compatible like the line below it???

document.getElementById('percentNumeric').innerHTML =...
0
894359
Asked:
894359
1 Solution
 
matt_mcswainCommented:
You can access it as a texNode instead, so something like:

   document.getElementById('percentNumeric').firstChild.nodeValue = Math.round(pbarw *100/barWidth);
0
 
NETTY4Commented:
Like this:

getObj('percentNumeric').innerHTML = Math.round(pbarw *100/barWidth);

0
 
894359Author Commented:
Tried that but doesn't work because of  index reference in function
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
NETTY4Commented:
What index are you talking about?
0
 
davidlars99Commented:
try like this and you really don't need  ...if (document.getElementsByName(objid)[0]) {.....


function getObj(objid) {
   if(document.getElementById)
          return document.getElementById(objid)
   if(document.all)
          return document.all[objid]
   if(document.layers)
          return document.layers[objid]
   return null
}
0
 
davidlars99Commented:
...if (document.getElementsByName(objid)[0]) {.....  this part will always be ignored by -->  if(document.getElementById)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now