Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

replace page values

hi,
i need some help in doing the following:

i have a tabel with the following data:

match 1            quest 1

ATD                   example data [PTD]
ATD                   example data [ATD]
ATD                   example data [ATD]
ATD                   example data [PTD]
ATD                   example data [PTD]

what i need to do is remove for example the [PTD] text in quest1 for blanks and if the data between [] is different from match1, change the text of match1 to the text between [] of quest1

this is the output i want to achieve

match 1            quest 1

PTD                   example data
ATD                   example data
ATD                   example data
PTD                   example data
PTD                   example data
0
eaweb
Asked:
eaweb
  • 12
  • 9
1 Solution
 
eawebAuthor Commented:
the text i match1 is coming like

 PTD 
 ATD 
etc...

I only need to change the PTD and ATD etc....
0
 
leakim971PluritechnicianCommented:
Check tis :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
	function cleanex(t) {
		var trs = document.getElementById(t).getElementsByTagName("tr");
		for(var i=0;i<trs.length;i++) {
			str = trs[i].cells(1).innerText.indexOf("[");
			end = trs[i].cells(1).innerText.indexOf("]");
			t0 = trs[i].cells(0).innerText;
			t1 = trs[i].cells(1).innerText.substring(str+1, end);
			alert(t1)
			if(t0!=t1) {
				trs[i].cells(0).innerText = t1;
				trs[i].cells(1).innerText = trs[i].cells(1).innerText.substr(0, str-1);
			}
//			trs[i].cells(1).innerText = trs[i].cells(1).innerText.substr(0, str-1);
		}
	}
</script>
</head>
<body onload="cleanex('myTable');">
<table id="myTable" border="1">
<tr><td>ATD</td><td>example data [PTD]</td></tr>
<tr><td>ATD</td><td>example data [ATD]</td></tr>
<tr><td>ATD</td><td>example data [ATD]</td></tr>
<tr><td>ATD</td><td>example data [PTD]</td></tr>
<tr><td>ATD</td><td>example data [PTD]</td></tr>
</table>
</body>
</html>

Open in new window

0
 
leakim971PluritechnicianCommented:
And this :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
	function cleanex(t) {
		var trs = document.getElementById(t).getElementsByTagName("tr");
		for(var i=0;i<trs.length;i++) {
			str = trs[i].cells(1).innerText.indexOf("[");
			end = trs[i].cells(1).innerText.indexOf("]");
			t0 = trs[i].cells(0).innerText;
			t1 = trs[i].cells(1).innerText.substring(str+1, end);
//			alert(t1)
			if(t0!=t1) {
				trs[i].cells(0).innerText = t1;
//				trs[i].cells(1).innerText = trs[i].cells(1).innerText.substr(0, str-1);
			}
			trs[i].cells(1).innerText = trs[i].cells(1).innerText.substr(0, str-1);
		}
	}
</script>
</head>
<body onload="cleanex('myTable');">
<table id="myTable" border="1">
<tr><td>ATD</td><td>example data [PTD]</td></tr>
<tr><td>ATD</td><td>example data [ATD]</td></tr>
<tr><td>ATD</td><td>example data [ATD]</td></tr>
<tr><td>ATD</td><td>example data [PTD]</td></tr>
<tr><td>ATD</td><td>example data [PTD]</td></tr>
</table>
</body>
</html>

Open in new window

0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
eawebAuthor Commented:
hi leakim971,
i went to implement your script for below table data but without success as i am also using javascript function to format  some number if their are any.
what i want to change using your code is bolded and underlined. the one with id "invest i only need to remove the last [...]  part (it will always be the last part) as the txt can also contain it"
here the table data:

<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;ATD&nbsp;</td>
<td >&nbsp;</td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                         [PTD]"); </script></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(9465000, 3), 2).toFixed(2); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap valign="top" align="left"><div id="posTyp"><script type="text/javascript"> getType("MAEDROS ABBIT"); </script></div></td>
<td id="invest"  >&nbsp;</td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script>&nbsp;<script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script>&nbsp;ATD</div></td>
<td >&nbsp;</td>
</tr>
 
<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;ATD&nbsp;</td>
<td >&nbsp;</td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(9465000, 3), 2).toFixed(2); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap valign="top" align="left"><div id="posTyp"><script type="text/javascript"> getType("MAEDROS ABBIT"); </script></div></td>
<td id="invest"  >&nbsp;</td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script>&nbsp;<script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE                         [PTD]"); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script>&nbsp;ATD</div></td>
<td >&nbsp;</td>
</tr>
<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;ATD&nbsp;</td>
<td >&nbsp;</td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(9465000, 3), 2).toFixed(2); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap valign="top" align="left"><div id="posTyp"><script type="text/javascript"> getType("MAEDROS ABBIT"); </script></div></td>
<td id="invest"  >&nbsp;</td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script>&nbsp;<script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script>&nbsp;ATD</div></td>
<td >&nbsp;</td>
</tr>
i hope you can help.
0
 
eawebAuthor Commented:
hi

the rows (tr) are being generated dynamically so if i can make it with two function will be great.
one javascript function that can remove the last [text] from the string so the  stripCostCurrency function can us it
one javascript function compare the text in the [text] with the text between the (&nbsp;) &nbsp;ATD&nbsp;. if they are the same the text between &nbsp; remain the same and if not the text between &nbsp; become the text in the [text].

like

stripCostCurrency(CompareRemoveText("MAEDROS VEARIS [PIT] CENTRE                          [PTD]")); remove the [PTD]

ReplaceText(&nbsp;ATD&nbsp;) replace ATD for PTD if the text in the function CompareRemoveText contains [PTD] and if it is the same like [ATD] the text will remain the same
0
 
Ray PaseurCommented:
What is your server-side scripting language?
0
 
leakim971PluritechnicianCommented:
>what i want to change using your code is bolded and underlined.

in cell(x), x is the column number. The first column number is zero.
In my example we've two columns : 0 and 1, so cell(0) and cell(1)
0
 
eawebAuthor Commented:
leamkin971,
i understood. but i also have a heading above the rows. i am testing but you code is only reading the first row (the heading). it not reading the hole table. see below the table sample i am using:

<table cellpadding="0" border="0" cellspacing="0" width="95%" id="myTable">
                   <tr valign=top>
                        <th id="stdAct" width="100">Date0</th>
                        <th id="stdAct">&nbsp;</th>
                        <th id="stdAct" width="100" align="right">amount2&nbsp;</th>
                        <th id="stdAct" >&nbsp;</th>
                        <th id="stdAct" width="100" align="right">amount4&nbsp;</th>
                        <th id="stdAct" >&nbsp;</th>
                        <th id="stdAct" width="100" align="right">Change6</th>
                        <th width="10">&nbsp;</th>
                        <th width="450" align="left">change Description8</th>
                        <th id="invest" >&nbsp;</th>
                        <th id="invest" align="right">Quantity10</th>
                        <th id="invest" >&nbsp;</th>
                        <th id="invest" align="center">Type12</th>
                        <th id="invest" >&nbsp;</th>
                        <th id="invest" align="center">Cost14</th>
                        <th id="invest" width="20">&nbsp;</th>
                        <th id="invest" align="right" colspan="2" width="200">Market&nbsp;Value16</th>
                        <th valign="top">&nbsp;</th>
                  </tr>
                  <tr><td colspan="14"><hr size="5"></td></tr>
                   <tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;ATD&nbsp;</td>
<td >&nbsp;</td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(9465000, 3), 2).toFixed(2); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap valign="top" align="left"><div id="posTyp"><script type="text/javascript"> getType("MAEDROS ABBIT"); </script></div></td>
<td id="invest"  >&nbsp;</td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script>&nbsp;<script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script>&nbsp;ATD</div></td>
<td >&nbsp;</td>
</tr>                  
</table>
0
 
eawebAuthor Commented:
see below the modified code

unction cleanex(t) {
            var trs = document.getElementById(t).getElementsByTagName("tr");
            for(var i=0;i<trs.length;i++) {
                  str = trs[i].cells(8).innerText.indexOf("[");
                  end = trs[i].cells(8).innerText.indexOf("]");
                  t0 = trs[i].cells(6).innerText;
                  t1 = trs[i].cells(8).innerText.substring(str+1, end);
                  alert(trs.length)
                  alert(str)
                  alert(end)
                  alert(t0)
                  alert(t1)
                  if(t0!=t1) {
                        trs[i].cells(6).innerText = t1;
                        trs[i].cells(8).innerText = trs[i].cells(8).innerText.substr(0, str-1);
                  }
                  trs[i].cells(8).innerText = trs[i].cells(8).innerText.substr(0, str-1);
            }
      }

it not reading all the table rows. only the first row
0
 
eawebAuthor Commented:
with the heading row it give an error at ---str = trs[i].cells(8).innerText.indexOf("[");--- as there is no "[" or "]" in that cell.

what will happen if the text contains more []. is there a way to find the [text] starting from the back as the text that needs to be change will be always in the back like stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]");
0
 
leakim971PluritechnicianCommented:
could you post a generated page (right click on the page in the browser and choose view source)
thanks
0
 
eawebAuthor Commented:
i fix the reading starting from the back with "lastIndexOf" instead of IndexOf but, i still have the problem while reading the first row with the heading
0
 
leakim971PluritechnicianCommented:
Use : var trs = document.getElementById(t).getElementsByTagName("tbody")[0].getElementsByTagName("tr");
instead :  var trs = document.getElementById(t).getElementsByTagName("tr");
0
 
eawebAuthor Commented:
here is the code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
	function stripCostCurrency (srcStr) {
	var tmp = srcStr;
	//var acctType = '';
	//if (acctType == "") {
		//tmp = tmp.substring(0, tmp.length-3);
	//}
alert(tmp)
	document.write(tmp);
}
	
	
	function cleanex(t) {
		var trs = document.getElementById(t).getElementsByTagName("tr");
		for(var i=0;i<=trs.length;i++) {
			str = trs[i].cells(8).innerText.lastIndexOf("[");
			end = trs[i].cells(8).innerText.lastIndexOf("]");
			t0 = trs[i].cells(6).innerText;
			t1 = trs[i].cells(8).innerText.substring(str+1, end);
			alert(trs.length)
			alert(str)
			alert(end)
			alert(t0)
			alert(t1)
			if(t0!=t1) {
				trs[i].cells(6).innerText = t1;
				//trs[i].cells(8).innerText = trs[i].cells(8).innerText.substr(0, str-1);
			}
			trs[i].cells(8).innerText = trs[i].cells(8).innerText.substr(0, str-1);
		}
	}
	

</script>
</head>
<body onload="cleanex('myTable2');">


<table cellpadding="0" border="0" cellspacing="0" width="95%" id="myTable2">

<tr valign=top>
                        <th id="stdAct" width="100">Date0</th>
                        <th id="stdAct">&nbsp;</th>
                        <th id="stdAct" width="100" align="right">amount2&nbsp;</th>
                        <th id="stdAct" >&nbsp;</th>
                        <th id="stdAct" width="100" align="right">amount4&nbsp;</th>
                        <th id="stdAct" >&nbsp;</th>
                        <th id="stdAct" width="100" align="right">Change6</th>
                        <th width="10">&nbsp;</th>
                        <th width="450" align="left">change Description8</th>
                        <th id="invest" >&nbsp;</th>
                        <th id="invest" align="right">Quantity10</th>
                        <th id="invest" >&nbsp;</th>
                        <th id="invest" align="center">Type12</th>
                        <th id="invest" >&nbsp;</th>
                        <th id="invest" align="center">Cost14</th>
                        <th id="invest" width="20">&nbsp;</th>
                        <th id="invest" align="right" colspan="2" width="200">Market&nbsp;Value16</th>
                        <th valign="top">&nbsp;</th>
                  </tr>
                  <tr><td colspan="14"><hr size="5"></td></tr>


<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;ATD&nbsp;</td>
<td >&nbsp;</td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(9465000, 3), 2).toFixed(2); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap valign="top" align="left"><div id="posTyp"><script type="text/javascript"> getType("MAEDROS ABBIT"); </script></div></td>
<td id="invest"  >&nbsp;</td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script>&nbsp;<script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script>&nbsp;ATD</div></td>
<td >&nbsp;</td>
</tr>


<tr class=RowOdd>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;ATD&nbsp;</td>
<td >&nbsp;</td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(9465000, 3), 2).toFixed(2); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap valign="top" align="left"><div id="posTyp"><script type="text/javascript"> getType("MAEDROS ABBIT"); </script></div></td>
<td id="invest"  >&nbsp;</td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script>&nbsp;<script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script>&nbsp;ATD</div></td>
<td >&nbsp;</td>
</tr>

<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;ATD&nbsp;</td>
<td >&nbsp;</td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(9465000, 3), 2).toFixed(2); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap valign="top" align="left"><div id="posTyp"><script type="text/javascript"> getType("MAEDROS ABBIT"); </script></div></td>
<td id="invest"  >&nbsp;</td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script>&nbsp;<script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script>&nbsp;ATD</div></td>
<td >&nbsp;</td>
</tr> 

 
			
</table>

</body>
</html>

Open in new window

0
 
eawebAuthor Commented:
using
var trs = document.getElementById(t).getElementsByTagName("tbody")[0].getElementsByTagName("tr");
still give me an error at
str = trs[i].cells(8).innerText.lastIndexOf("[");
0
 
leakim971PluritechnicianCommented:
you need to put row(s) header of your table in < thead > ... < /thead> tags
and the other row(s) of your table in < tbody >... < /tbody > 


<table cellpadding="0" border="0" cellspacing="0" width="95%" id="myTable2">
<thead>
<tr valign=top>
                        <th id="stdAct" width="100">Date0</th>
                        <th id="stdAct">&nbsp;</th>
                        <th id="stdAct" width="100" align="right">amount2&nbsp;</th>
                        <th id="stdAct" >&nbsp;</th>
                        <th id="stdAct" width="100" align="right">amount4&nbsp;</th>
                        <th id="stdAct" >&nbsp;</th>
                        <th id="stdAct" width="100" align="right">Change6</th>
                        <th width="10">&nbsp;</th>
                        <th width="450" align="left">change Description8</th>
                        <th id="invest" >&nbsp;</th>
                        <th id="invest" align="right">Quantity10</th>
                        <th id="invest" >&nbsp;</th>
                        <th id="invest" align="center">Type12</th>
                        <th id="invest" >&nbsp;</th>
                        <th id="invest" align="center">Cost14</th>
                        <th id="invest" width="20">&nbsp;</th>
                        <th id="invest" align="right" colspan="2" width="200">Market&nbsp;Value16</th>
                        <th valign="top">&nbsp;</th>
                  </tr>
                  <tr><td colspan="14"><hr size="5"></td></tr>
</thead>
<tbody>
<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;ATD&nbsp;</td>
<td >&nbsp;</td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(9465000, 3), 2).toFixed(2); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap valign="top" align="left"><div id="posTyp"><script type="text/javascript"> getType("MAEDROS ABBIT"); </script></div></td>
<td id="invest"  >&nbsp;</td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script>&nbsp;<script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script>&nbsp;ATD</div></td>
<td >&nbsp;</td>
</tr>


<tr class=RowOdd>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;ATD&nbsp;</td>
<td >&nbsp;</td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(9465000, 3), 2).toFixed(2); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap valign="top" align="left"><div id="posTyp"><script type="text/javascript"> getType("MAEDROS ABBIT"); </script></div></td>
<td id="invest"  >&nbsp;</td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script>&nbsp;<script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script>&nbsp;ATD</div></td>
<td >&nbsp;</td>
</tr>

<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;ATD&nbsp;</td>
<td >&nbsp;</td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(9465000, 3), 2).toFixed(2); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap valign="top" align="left"><div id="posTyp"><script type="text/javascript"> getType("MAEDROS ABBIT"); </script></div></td>
<td id="invest"  >&nbsp;</td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script>&nbsp;<script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script>&nbsp;ATD</div></td>
<td >&nbsp;</td>
</tr> 

</tbody>

Open in new window

0
 
leakim971PluritechnicianCommented:
full page :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
	function stripCostCurrency (srcStr) {
	var tmp = srcStr;
	//var acctType = '';
	//if (acctType == "") {
		//tmp = tmp.substring(0, tmp.length-3);
	//}
alert(tmp)
	document.write(tmp);
}
	
	
	function cleanex(t) {
		var trs = document.getElementById(t).getElementsByTagName("tbody")[0].getElementsByTagName("tr");
		for(var i=0;i<=trs.length;i++) {
			str = trs[i].cells(8).innerText.lastIndexOf("[");
			end = trs[i].cells(8).innerText.lastIndexOf("]");
			t0 = trs[i].cells(6).innerText;
			t1 = trs[i].cells(8).innerText.substring(str+1, end);
			alert(trs.length)
			alert(str)
			alert(end)
			alert(t0)
			alert(t1)
			if(t0!=t1) {
				trs[i].cells(6).innerText = t1;
				//trs[i].cells(8).innerText = trs[i].cells(8).innerText.substr(0, str-1);
			}
			trs[i].cells(8).innerText = trs[i].cells(8).innerText.substr(0, str-1);
		}
	}
	

</script>
</head>
<body onload="cleanex('myTable2');">


<table cellpadding="0" border="0" cellspacing="0" width="95%" id="myTable2">
<thead>
<tr valign=top>
                        <th id="stdAct" width="100">Date0</th>
                        <th id="stdAct">&nbsp;</th>
                        <th id="stdAct" width="100" align="right">amount2&nbsp;</th>
                        <th id="stdAct" >&nbsp;</th>
                        <th id="stdAct" width="100" align="right">amount4&nbsp;</th>
                        <th id="stdAct" >&nbsp;</th>
                        <th id="stdAct" width="100" align="right">Change6</th>
                        <th width="10">&nbsp;</th>
                        <th width="450" align="left">change Description8</th>
                        <th id="invest" >&nbsp;</th>
                        <th id="invest" align="right">Quantity10</th>
                        <th id="invest" >&nbsp;</th>
                        <th id="invest" align="center">Type12</th>
                        <th id="invest" >&nbsp;</th>
                        <th id="invest" align="center">Cost14</th>
                        <th id="invest" width="20">&nbsp;</th>
                        <th id="invest" align="right" colspan="2" width="200">Market&nbsp;Value16</th>
                        <th valign="top">&nbsp;</th>
                  </tr>
                  <tr><td colspan="14"><hr size="5"></td></tr>
</thead>
<tbody>
<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;ATD&nbsp;</td>
<td >&nbsp;</td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(9465000, 3), 2).toFixed(2); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap valign="top" align="left"><div id="posTyp"><script type="text/javascript"> getType("MAEDROS ABBIT"); </script></div></td>
<td id="invest"  >&nbsp;</td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script>&nbsp;<script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script>&nbsp;ATD</div></td>
<td >&nbsp;</td>
</tr>


<tr class=RowOdd>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;ATD&nbsp;</td>
<td >&nbsp;</td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(9465000, 3), 2).toFixed(2); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap valign="top" align="left"><div id="posTyp"><script type="text/javascript"> getType("MAEDROS ABBIT"); </script></div></td>
<td id="invest"  >&nbsp;</td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script>&nbsp;<script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script>&nbsp;ATD</div></td>
<td >&nbsp;</td>
</tr>

<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;</td>
<td id="stdAct">&nbsp;</td>
<td id="stdAct" nowrap align="right" valign="top">&nbsp;ATD&nbsp;</td>
<td >&nbsp;</td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(9465000, 3), 2).toFixed(2); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap valign="top" align="left"><div id="posTyp"><script type="text/javascript"> getType("MAEDROS ABBIT"); </script></div></td>
<td id="invest"  >&nbsp;</td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script>&nbsp;<script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE                          [PTD]"); </script></div></td>
<td id="invest" >&nbsp;</td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script>&nbsp;ATD</div></td>
<td >&nbsp;</td>
</tr> 

</tbody>
			
</table>

</body>
</html>

Open in new window

0
 
eawebAuthor Commented:
Still getting the error
Webpage error details
Message: 'undefined' is null or not an object
Line: 354
Char: 4
this line is at --str = trs[i].cells(8).innerText.lastIndexOf("[");---

0
 
leakim971PluritechnicianCommented:
Replace : for(var i=0;i<=trs.length;i++) {
By : for(var i=0;i
0
 
eawebAuthor Commented:
Hi leakim971,

great thank you very very much.
0
 
leakim971PluritechnicianCommented:
You're very welcome! Thanks for the points!
0
 
eawebAuthor Commented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

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