eaweb
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
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
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>
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>
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"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></td>
<td id="invest" > </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" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></div></td>
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top"> <div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script> ATD</div></ td>
<td > </td>
</tr>
<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></td>
<td id="invest" > </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" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></div></td>
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top"> <div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script> ATD</div></ td>
<td > </td>
</tr>
<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></td>
<td id="invest" > </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" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></div></td>
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top"> <div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script> ATD</div></ td>
<td > </td>
</tr>
i hope you can help.
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"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS
<td id="invest" > </td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(
<td id="invest" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top">
<td > </td>
</tr>
<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS
<td id="invest" > </td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(
<td id="invest" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top">
<td > </td>
</tr>
<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS
<td id="invest" > </td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(
<td id="invest" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top">
<td > </td>
</tr>
i hope you can help.
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 ( ) ATD . if they are the same the text between remain the same and if not the text between become the text in the [text].
like
stripCostCurrency(CompareR emoveText( "MAEDROS VEARIS [PIT] CENTRE [PTD]")); remove the [PTD]
ReplaceText( ATD  ;) 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
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 ( ) ATD . if they are the same the text between remain the same and if not the text between become the text in the [text].
like
stripCostCurrency(CompareR
ReplaceText( ATD 
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)
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)
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"> </th>
<th id="stdAct" width="100" align="right">amount2  ;</th>
<th id="stdAct" > </th>
<th id="stdAct" width="100" align="right">amount4  ;</th>
<th id="stdAct" > </th>
<th id="stdAct" width="100" align="right">Change6</th>
<th width="10"> </th>
<th width="450" align="left">change Description8</th>
<th id="invest" > </th>
<th id="invest" align="right">Quantity10</ th>
<th id="invest" > </th>
<th id="invest" align="center">Type12</th>
<th id="invest" > </th>
<th id="invest" align="center">Cost14</th>
<th id="invest" width="20"> </th>
<th id="invest" align="right" colspan="2" width="200">Market Va lue16</th>
<th valign="top"> </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"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD&nbs p;</td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></td>
<td id="invest" > </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" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></div></td>
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top"> <div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script> ATD</div></ td>
<td > </td>
</tr>
</table>
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"> </th>
<th id="stdAct" width="100" align="right">amount2 
<th id="stdAct" > </th>
<th id="stdAct" width="100" align="right">amount4 
<th id="stdAct" > </th>
<th id="stdAct" width="100" align="right">Change6</th>
<th width="10"> </th>
<th width="450" align="left">change Description8</th>
<th id="invest" > </th>
<th id="invest" align="right">Quantity10</
<th id="invest" > </th>
<th id="invest" align="center">Type12</th>
<th id="invest" > </th>
<th id="invest" align="center">Cost14</th>
<th id="invest" width="20"> </th>
<th id="invest" align="right" colspan="2" width="200">Market Va
<th valign="top"> </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"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD&nbs
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS
<td id="invest" > </td>
<td id="invest" nowrap align="right" valign="top"><div id="posQty"><script type="text/javascript"> roundNumber(formatNumbers(
<td id="invest" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top">
<td > </td>
</tr>
</table>
ASKER
see below the modified code
unction cleanex(t) {
var trs = document.getElementById(t) .getElemen tsByTagNam e("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
unction cleanex(t) {
var trs = document.getElementById(t)
for(var i=0;i<trs.length;i++) {
str = trs[i].cells(8).innerText.
end = trs[i].cells(8).innerText.
t0 = trs[i].cells(6).innerText;
t1 = trs[i].cells(8).innerText.
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.
}
trs[i].cells(8).innerText = trs[i].cells(8).innerText.
}
}
it not reading all the table rows. only the first row
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]");
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
could you post a generated page (right click on the page in the browser and choose view source)
thanks
thanks
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) .getElemen tsByTagNam e("tbody") [0].getEle mentsByTag Name("tr") ;
instead : var trs = document.getElementById(t) .getElemen tsByTagNam e("tr");
instead : var trs = document.getElementById(t)
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"> </th>
<th id="stdAct" width="100" align="right">amount2 </th>
<th id="stdAct" > </th>
<th id="stdAct" width="100" align="right">amount4 </th>
<th id="stdAct" > </th>
<th id="stdAct" width="100" align="right">Change6</th>
<th width="10"> </th>
<th width="450" align="left">change Description8</th>
<th id="invest" > </th>
<th id="invest" align="right">Quantity10</th>
<th id="invest" > </th>
<th id="invest" align="center">Type12</th>
<th id="invest" > </th>
<th id="invest" align="center">Cost14</th>
<th id="invest" width="20"> </th>
<th id="invest" align="right" colspan="2" width="200">Market Value16</th>
<th valign="top"> </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"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></td>
<td id="invest" > </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" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></div></td>
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script> ATD</div></td>
<td > </td>
</tr>
<tr class=RowOdd>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></td>
<td id="invest" > </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" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></div></td>
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script> ATD</div></td>
<td > </td>
</tr>
<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></td>
<td id="invest" > </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" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></div></td>
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script> ATD</div></td>
<td > </td>
</tr>
</table>
</body>
</html>
ASKER
using
var trs = document.getElementById(t) .getElemen tsByTagNam e("tbody") [0].getEle mentsByTag Name("tr") ;
still give me an error at
str = trs[i].cells(8).innerText. lastIndexO f("[");
var trs = document.getElementById(t)
still give me an error at
str = trs[i].cells(8).innerText.
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 >
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"> </th>
<th id="stdAct" width="100" align="right">amount2 </th>
<th id="stdAct" > </th>
<th id="stdAct" width="100" align="right">amount4 </th>
<th id="stdAct" > </th>
<th id="stdAct" width="100" align="right">Change6</th>
<th width="10"> </th>
<th width="450" align="left">change Description8</th>
<th id="invest" > </th>
<th id="invest" align="right">Quantity10</th>
<th id="invest" > </th>
<th id="invest" align="center">Type12</th>
<th id="invest" > </th>
<th id="invest" align="center">Cost14</th>
<th id="invest" width="20"> </th>
<th id="invest" align="right" colspan="2" width="200">Market Value16</th>
<th valign="top"> </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"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></td>
<td id="invest" > </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" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></div></td>
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script> ATD</div></td>
<td > </td>
</tr>
<tr class=RowOdd>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></td>
<td id="invest" > </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" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></div></td>
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script> ATD</div></td>
<td > </td>
</tr>
<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></td>
<td id="invest" > </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" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></div></td>
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script> ATD</div></td>
<td > </td>
</tr>
</tbody>
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"> </th>
<th id="stdAct" width="100" align="right">amount2 </th>
<th id="stdAct" > </th>
<th id="stdAct" width="100" align="right">amount4 </th>
<th id="stdAct" > </th>
<th id="stdAct" width="100" align="right">Change6</th>
<th width="10"> </th>
<th width="450" align="left">change Description8</th>
<th id="invest" > </th>
<th id="invest" align="right">Quantity10</th>
<th id="invest" > </th>
<th id="invest" align="center">Type12</th>
<th id="invest" > </th>
<th id="invest" align="center">Cost14</th>
<th id="invest" width="20"> </th>
<th id="invest" align="right" colspan="2" width="200">Market Value16</th>
<th valign="top"> </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"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></td>
<td id="invest" > </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" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></div></td>
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script> ATD</div></td>
<td > </td>
</tr>
<tr class=RowOdd>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></td>
<td id="invest" > </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" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></div></td>
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script> ATD</div></td>
<td > </td>
</tr>
<tr class=RowEven>
<td id="stdAct" nowrap align="right" valign="top">14 Jan 2010</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> 128.47</td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> </td>
<td id="stdAct"> </td>
<td id="stdAct" nowrap align="right" valign="top"> ATD </td>
<td > </td>
<td valign="top"><script type="text/javascript"> stripCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></td>
<td id="invest" > </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" > </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" > </td>
<td id="invest" nowrap valign="top" align="right"><div id="posCst"><script type="text/javascript"> getCost("MAEDROS ABBIT"); </script> <script type="text/javascript"> printCostCurrency("MAEDROS VEARIS [PIT] CENTRE [PTD]"); </script></div></td>
<td id="invest" > </td>
<td id="invest" nowrap colspan="2" align="right"valign="top"><div id="posVal"><script type="text/javascript"> formatNumbers(-12847, 2); </script> ATD</div></td>
<td > </td>
</tr>
</tbody>
</table>
</body>
</html>
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. lastIndexO f("[");---
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi leakim971,
great thank you very very much.
great thank you very very much.
You're very welcome! Thanks for the points!
ASKER
leakim971 do have a chance to look into https://www.experts-exchange.com/questions/26368900/javascript-paging-in-xsl.html for me?
ASKER
PTD
ATD
etc...
I only need to change the PTD and ATD etc....