Jump to content

Recommended Posts

Hi @ll,I'm trying to change all comma's in a table with point so I can load the table in excel without any problems.I want to create a short script to replace all comma's to points, but it isn't working.I'm pretty new to scripting and trying to help myself (especially via W3schools) so my question may be a bit "simple/stupid" At first i've tried this code:

var Table = document.getElementById('members');Table.replaceAll(",", ".");

But it doesn't work this way. Probably because the complete table is not a string? Currently I have this code:

var Table = document.getElementById('members');var rowLength = Table.rows.length;for (i = 1; i < rowLength; i++) {var Cells = Table.rows.item(i).cells;var cellLength = Cells.length;for (var j = 0; j < cellLenght; j++) {  var cellVal = Cells.item(j).innerHTML;  cellVal.replaceAll(",", ".");}}

Also this isn't working. I'm getting the error: Cannot convert 'Table' to object at line 2.I'm pretty sure the ID 'members' is the right ID.The table that needs to change is located here. What am I doing wrong?Should the first scipt also work?Thnx in advance!

Edited by nero987
Link to post
Share on other sites

"Table" might be a reserved word, at least this forum seems to think it is. The same with "Cells". The first code doesn't work, an HTML element does not have a method called "replaceAll". In fact, nothing in Javascript has a "replaceAll" method. I would use split and join: new_string = old_string.split(",").join("."); The second code would work better, but you're not doing anything with the string after you replace it. You need to write the replaced string back to the cell.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...