SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Displaying a "»" on a button

    Hello everyone!

    I'm trying to display a "»" character on a button called "Advanced Search »", and when it's clicked, the button changes to "« Basic Search".

    I can initially set the button to display the "»" character, but when I use Javascript to change the button's value, it displays the string "»" on the button, and not the character itself.

    The solution I've found is to use a "button" element instead, and to change it's innerHTML property. However, this doesn't work in Firefox, and makes my code a tad bit inconsistent.

    If somebody can show me how it's done, I'd really appreciate it!

    Many thanks in advance...

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Setting a buttons innerHTML works in Firefox, what error do you get?

    Code:
    <button id="b">test</button>
    
    <script>
    document.getElementById("b").innerHTML = "&raquo;"
    </script>

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, my mistake. I was meant to say using the button element doesn't work as expected. It behaves like a submit button, when I don't want to submit the form.

    I would still prefer using an input element of type button, since that would be consistent with my other form elements.

    Thanks for the reply

  4. #4
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can make it act like a regular button by setting the type attribute to "button"
    Code:
    <button type="button">I won't submit the form</button>

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Pepejeria,

    The problem I had with using a button element is that it's inconsistent with the other form elements, and because it submits by default in Firefox.

    I've resorted to using the actual character "" instead of the entity reference. It seems to be doing the trick...

    Thanks for your feedback...

  6. #6
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Naseej-Designer View Post
    ...and because it submits by default in Firefox.
    Again, just set the type to button and it will not submit


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
  •