Results 1 to 7 of 7

Thread: Special Characters

  1. #1
    Join Date
    Feb 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Special Characters

    Hi

    Is it possible to write the division symbol ÷ or ÷ to a html text box with javascript?

    I have done this before but since changing web hostings the symbol appears as a square.

    Below are three lines from the script that used to work.
    myvar4="÷";
    var v= "" + myvar1[h] + " " +myvar4+" " + myvar2[h] + " = ";
    document.quizform.question.value=v;

    Any help gratefully recieved.

    Cheers
    Matilda

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Code:
    myvar4="%";
    var v= "" + myvar1[h] + " " +myvar4+" " + myvar2[h] + " = ";
    document.quizform.question.value=v;
    Should work.
    Last edited by Nile; 02-22-2008 at 09:58 PM.
    Jeremy | jfein.net

  3. #3
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    I believe http://www.asciitable.com/ will be helpful

    the percentage sign character code is
    Code:
    %

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    @boogyman
    I had the same problem, it displays it normaly,
    You have to put a:
    Code:
    [ COLOR="Black"][/COLOR]
    In between one of the letters.
    Edit:
    I beat you to it!
    Jeremy | jfein.net

  5. #5
    Join Date
    Feb 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    myvar4="÷";
    var v= "" + myvar1[h] + " " +myvar4+" " + myvar2[h] + " = ";
    document.quizform.question.value=v;

    does not work

    the special character code displays rather than the divide symbol

  6. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Can we see all of your js?
    Also please wrap your codes with a [CODE]---[/CODE] Things!
    Jeremy | jfein.net

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It may not matter how you get the character into the the value of the text input. This will do it (assuming that the rest of the code is correct):

    Code:
    myvar4="\xf7";
    var v= "" + myvar1[h] + " " +myvar4+" " + myvar2[h] + " = ";
    document.quizform.question.value=v;
    But if the page isn't being served with a compatible charset, it will be replaced by a box, a question mark, etc.

    I think this may be the problem, because you say it was working fine until you changed hosts. It is ultimately the host which determines the charset that a page is served with. You can use a meta tag to try to override this, but it may not always work, try this one:

    HTML Code:
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    in the head of the page, right after the title tag. Remove any other meta tags (if there are any others) that set the content and/or charset.

    Be sure to clear the cache in your browser when viewing the changed page online.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •