Link to home
Start Free TrialLog in
Avatar of eaweb
eawebFlag for undefined

asked on

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
Avatar of eaweb
eaweb
Flag of undefined image

ASKER

the text i match1 is coming like

 PTD 
 ATD 
etc...

I only need to change the PTD and ATD etc....
Avatar of leakim971
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

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

Avatar of eaweb

ASKER

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.
Avatar of eaweb

ASKER

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
What is your server-side scripting language?
>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)
Avatar of eaweb

ASKER

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>
Avatar of eaweb

ASKER

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
Avatar of eaweb

ASKER

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]");
could you post a generated page (right click on the page in the browser and choose view source)
thanks
Avatar of eaweb

ASKER

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
Use : var trs = document.getElementById(t).getElementsByTagName("tbody")[0].getElementsByTagName("tr");
instead :  var trs = document.getElementById(t).getElementsByTagName("tr");
Avatar of eaweb

ASKER

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

Avatar of eaweb

ASKER

using
var trs = document.getElementById(t).getElementsByTagName("tbody")[0].getElementsByTagName("tr");
still give me an error at
str = trs[i].cells(8).innerText.lastIndexOf("[");
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

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

Avatar of eaweb

ASKER

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("[");---

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eaweb

ASKER

Hi leakim971,

great thank you very very much.
You're very welcome! Thanks for the points!