hankknight
asked on
Show character instead of entity using JavaScript
Hello,
I use server-side code to convert special characters into html entities.
However the entities look very ugly in the form input boxes.
Can I use JavaScript to turn the entities back into characters?
For example: <input type="text" name="t1" value="© 2008" />
should show © instead of ©
I use many other entities as well, that is just an example. Can I convert all entities to characters in all input boxes using only JavaScript?
I use server-side code to convert special characters into html entities.
However the entities look very ugly in the form input boxes.
Can I use JavaScript to turn the entities back into characters?
For example: <input type="text" name="t1" value="© 2008" />
should show © instead of ©
I use many other entities as well, that is just an example. Can I convert all entities to characters in all input boxes using only JavaScript?
<script>
var el = document.getElementById('t1');
el.value = el.value.replace(/[&]copy[;]/,'©');
</script>
<input type="text" name="t1" value="© 2008" />
ASKER
sh0e, your idea is good but not enough.
I use there are countless entities, not just 1.
Could your idea some how be incorporated with this link?
http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_html_entity_decode/
I use there are countless entities, not just 1.
Could your idea some how be incorporated with this link?
http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_html_entity_decode/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
&copy;