Click here to Skip to main content
16,016,180 members
Please Sign up or sign in to vote.
2.67/5 (3 votes)
See more:
Scenario:

A table and or any other HTML elements are already present on the page with data in them. I should read the data from each element and wrap custom tags around the data which is of specific type.(This should be done on the onload event)

HTML
<table border="1"
id = "Table1">
<tr>
<td>CO@Property</td>
</tr>
<tr>
<td>Tag:Plugin@Property</td>
</tr>
</table>
<input id="UserTag1" type="text" value="Random1" style="text-align: right; width:50em">
<input id="UserTag2" type="text" value="Tag:Random1" style="text-align: right; width:50em">


Any data in any input field starting with "Tag:" should be enclosed in a Custom Tag

HTML
<CSTag InputType = "Tag" TagValue = "value the user entered" />


So After OnLoad the code should look like this:

HTML
<table border="1"
id = "Table1">
<tr>
<td>CO@Property</td>
</tr>
<tr>
<td><CSTag InputType = "Tag" TagValue = "Plugin@Property" /></td>
</tr>
</table>
<input id="UserTag1" type="text" value="Random1" style="text-align: right; width:50em">
<input id="UserTag2" type="text" value="<CSTag InputType = "Tag" TagValue = "Random1" />"style="text-align: right; width:50em">


How do i achieve this? I want to pull out user data of specific type and wrap them around tags.
Posted
Comments
Sergey Alexandrovich Kryukov 18-Jul-12 16:37pm    
Custom tag? Bad idea. Event if I can assume it can work with some browsers, other do not have to support it. All tags should be standard, which should not prevent you from reaching your ultimate goals.
--SA

1 solution

Please see my comment and better don't try to use a "custom tag". Other than that, there is no problem. You can use document.getElementById to get some element and assign its property innerHTML. Please see:
http://www.w3schools.com/jsref/met_doc_getelementbyid.asp[^],
http://www.w3schools.com/jsref/prop_html_innerhtml.asp[^].

Please see the code sample shown in the second page referenced above.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900