If anyone can assist with this issue I’m having I would greatly appreciate it, greatly! I simply want to replace every <TD> tag with <TD>__ while preserving any attributes within the tag, as well as the content it surrounds.
Here are the results I’m getting so far. Though it works as desired, the attributes within the TD tags are being stripped out. The attributes such as class, height, etc, need to stay upon the flagTags function being ran.
I only want to replace the “>” portion of each <td> tag with “>__”.
Thank you in advance!
[CODE]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<title>Untitled Document</title>
<script type=”text/JavaScript”>
function flagTags(){
var content = document.myform.code.value;
var re= new RegExp(‘<td[^><]*>|<td[^><]*>’,’g’)
content = content.replace(re,'<td>__’);
document.myform.code.value = content;
}
function unflagTags(){
var content = document.myform.code.value;
content = content.replace(/<td>__/g,'<td>’);
document.myform.code.value = content;
}
</script>
</head>
<body>a
<form name=”myform”>
<textarea name=”code” cols=”100″ rows=”9″ value=””><table border=”1″ width=”100%” id=”table1″>
<tr>
<th> </th>
<td class=’something’> </td>
<td class=’something’>Some Content</td>
<td>Some More Content</td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</textarea>
<br>
<input type=”button” value=”Add TD Flags” onclick=”flagTags()”>
<br>
<input type=”button” value=”Remove TD Flags” onclick=”unflagTags()”>
<br>
<input type=”reset” value=”Reset”>
</form>
</body>
</html>