HighTechTalks DotNet Forums  

Javascript problem with innerHTML

Dotnet Scripting microsoft.public.dotnet.scripting


Discuss Javascript problem with innerHTML in the Dotnet Scripting forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
RateTheBuilder
 
Posts: n/a

Default Javascript problem with innerHTML - 08-31-2007 , 10:28 AM






I am having trouble with the following function. I am trying to change the
ID of a hidden form object inside a table row. I have used alert() to test
where it breaks and it seems to be on the last line of the function where I
am trying to place the new text back into the table row. Anyone any ideas
where I'm going wrong as I'm not a great Javascript coder. Or even if you
know a better way to carry out what I am trying to do.

Thanks in advance.

this.onDrop = function(table, droppedRow) {
var rows = table.tBodies[0].rows;
var rowsCount = parseInt(rows.length);

for (var x = 0; x <= rowsCount - 1; x++)
{
//Get string contents of row
var curRowString = rows[x].innerHTML;

//Find where ID tag is
var IDStart = curRowString.indexOf("ID");

//Find > immediately after ID tag
var IDEnd = curRowString.indexOf(">", IDStart);

//Get ID value
var IDVal = curRowString.substring(IDStart+5,IDEnd)

//Replace old ID with new ID
var oldID = "ID" + IDVal;
var newID = "ID" + (x+1);
var newRowString = curRowString.replace(oldID, newID);

//*********** Crashes on line below ***************
rows[x].innerHTML = newRowString;
}
}




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.