-
Q: Javascript Option object and HTML special characters
Does anybody know if the Option object in Javascript is unable to display
HTML special characters like ", >, ?
Example:
I would like to display the trademark character TM ( ) by dynamically
adding an option to a dropdown using the Option object. However, the
gets displayed as is, without getting converted to the TM character.
Try the sample code below. I have two options that are statically displayed
with the special characters and they display fine. But when I try to add
a dynamic option with the special character, it does not display properly.
Any help/suggestions will be greately appreciated.
Sample Code:
<html>
<script>
function AddOption()
{
var l;
l = document.joydeep.cbo.length;
document.joydeep.cbo[l] = new Option("CompactFlash",123,false,false);
}
</script>
<body>
<form name="joydeep">
<SELECT name="cbo" onchange=AddOption()>
<OPTION value="1">Trademarked Item</OPTION>
<OPTION value="2">Copyrighted Item®</OPTION>
</SELECT>
</form>
</body>
</html>
-
Re: Javascript Option object and HTML special characters
According the WC3 specs, the correct character entity for trademark is
either ™ or ™
Try this
var strOption = "CompactFlash™"
--
Michael Shutt
Please respond to newsgroup as I will not return direct emails.
"JT" <joydeept@yahoo.com> wrote in message news:3b2e8f12$1@news.devx.com...
>
> Does anybody know if the Option object in Javascript is unable to display
> HTML special characters like ", >, ?
>
> Example:
> I would like to display the trademark character TM ( ) by
dynamically
> adding an option to a dropdown using the Option object. However, the
> gets displayed as is, without getting converted to the TM character.
>
> Try the sample code below. I have two options that are statically
displayed
> with the special characters and they display fine. But when I try to add
> a dynamic option with the special character, it does not display properly.
>
> Any help/suggestions will be greately appreciated.
>
>
> Sample Code:
> <html>
> <script>
>
> function AddOption()
> {
> var l;
> l = document.joydeep.cbo.length;
> document.joydeep.cbo[l] = new
Option("CompactFlash",123,false,false);
> }
> </script>
> <body>
> <form name="joydeep">
>
> <SELECT name="cbo" onchange=AddOption()>
> <OPTION value="1">Trademarked Item</OPTION>
> <OPTION value="2">Copyrighted Item®</OPTION>
> </SELECT>
>
> </form>
> </body>
> </html>
-
Re: Q: Javascript Option object and HTML special characters
Check this code snippet out.. This works
function AddOption()
{
var l;
l = document.joydeep.cbo.length;
document.joydeep.cbo[l] = new Option("",123,false,false);
document.joydeep.cbo[l].innerHTML = "CompactFlash";
}
cheers,
Madhu
"JT" <joydeept@yahoo.com> wrote:
>
>Does anybody know if the Option object in Javascript is unable to display
>HTML special characters like ", >, ™ ?
>
>Example:
>I would like to display the trademark character TM ( ™ ) by dynamically
>adding an option to a dropdown using the Option object. However, the ™
>gets displayed as is, without getting converted to the TM character.
>
>Try the sample code below. I have two options that are statically displayed
>with the special characters and they display fine. But when I try to add
>a dynamic option with the special character, it does not display properly.
>
>Any help/suggestions will be greately appreciated.
>
>
>Sample Code:
><html>
><script>
>
>function AddOption()
>{
> var l;
> l = document.joydeep.cbo.length;
> document.joydeep.cbo[l] = new Option("CompactFlash™",123,false,false);
>}
></script>
><body>
><form name="joydeep">
>
><SELECT name="cbo" onchange=AddOption()>
><OPTION value="1">Trademarked Item™</OPTION>
><OPTION value="2">Copyrighted Item®</OPTION>
></SELECT>
>
></form>
></body>
></html>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks