Solved

replace page values

Posted on 2010-09-06
24
208 Views
Last Modified: 2013-11-19
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
Comment
Question by:eaweb
  • 12
  • 9
24 Comments
 

Author Comment

by:eaweb
ID: 33613495
the text i match1 is coming like

 PTD 
 ATD 
etc...

I only need to change the PTD and ATD etc....
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33613530
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
 
LVL 82

Expert Comment

by:leakim971
ID: 33613534
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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

Author Comment

by:eaweb
ID: 33617709
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
 

Author Comment

by:eaweb
ID: 33620793
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
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 33622229
What is your server-side scripting language?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33622622
>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
 

Author Comment

by:eaweb
ID: 33626813
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
 

Author Comment

by:eaweb
ID: 33626876
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
 

Author Comment

by:eaweb
ID: 33627409
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
 
LVL 82

Expert Comment

by:leakim971
ID: 33627427
could you post a generated page (right click on the page in the browser and choose view source)
thanks
0
 

Author Comment

by:eaweb
ID: 33627503
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
 
LVL 82

Expert Comment

by:leakim971
ID: 33627593
Use : var trs = document.getElementById(t).getElementsByTagName("tbody")[0].getElementsByTagName("tr");
instead :  var trs = document.getElementById(t).getElementsByTagName("tr");
0
 

Author Comment

by:eaweb
ID: 33627665
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
 

Author Comment

by:eaweb
ID: 33628455
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
 
LVL 82

Expert Comment

by:leakim971
ID: 33628717
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
 
LVL 82

Expert Comment

by:leakim971
ID: 33628721
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
 

Author Comment

by:eaweb
ID: 33629030
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
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 33629085
Replace : for(var i=0;i<=trs.length;i++) {
By : for(var i=0;i
0
 

Author Comment

by:eaweb
ID: 33640786
Hi leakim971,

great thank you very very much.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33640810
You're very welcome! Thanks for the points!
0
 

Author Comment

by:eaweb
ID: 33640876
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Show MP4 file and close (HTA) 3 20
Compute age Html 2 24
CURL sending XML without spaces PHP 5 28
Increase image taller on inner pages 2 10
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question