dcsimg
Help for getElementById() method..
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rocky_Khan
Posted On:   Tuesday, November 1, 2011 06:43 AM

I am using javascript for adding and removing rows from table as per user require ment like if we press ADDROW button it adds extra row to table and if we pressREMOVEROW it delets the last row.. Now i want to access the data from textbox like this.. var crpt = document.getElementById("itrtr2").value; //no. of rows for(var k=1;k <=crpt;k++) { qtyc = document.getElementById("txtRowc3"+k).value; unit_pricec = document.getElementById("txtRowc5"+k).value; alert('QTYC:'+qtyc+' UPC:'+unit_pricec); cttl = qtyc * unit_pricec; document.getElementById("txtRowc6"+k).value = cttl.toFixed(2); csbttl = csbttl +    More>>

I am using javascript for adding and removing rows from table as per user require ment like if we press ADDROW button it adds extra row to table and if we pressREMOVEROW it delets the last row.. Now i want to access the data from textbox like this..


var crpt = document.getElementById("itrtr2").value; //no. of rows

for(var k=1;k <=crpt;k++)

{

qtyc = document.getElementById("txtRowc3"+k).value;

unit_pricec = document.getElementById("txtRowc5"+k).value;

alert('QTYC:'+qtyc+' UPC:'+unit_pricec);

cttl = qtyc * unit_pricec;

document.getElementById("txtRowc6"+k).value = cttl.toFixed(2);

csbttl = csbttl + cttl;

}

document.getElementById("subttlC").value=csbttl.toFixed(2);


it shows the value of textRowc3i in qtyc in alert box but also givs error document.getElementById("txtRowc3"+k) is null..


I tried for this but problem is not solved please help...
Thank You...

   <<Less

Re: Help for getElementById() method..

Posted By:   vijay_satlawar  
Posted On:   Thursday, November 24, 2011 02:13 AM

There can be two possibilities:

First of all check whether the row with the mentioned ID is present.

if it is present then try to use

pasrseInt method on crpt.

i.e.

for(var k=1;k<=parseInt(crpt);k++)
{
//code goes here
}
now it will work
About | Sitemap | Contact