SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot ejg's Avatar
    Join Date
    Jun 2007
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    star rating - not sticky in IE

    I have some star rating code that is acting differently in IE (6 and 7) than Firefox (2.0 and 3.0).

    My requirements are that the user selects all the rows and then submits all five ratings to the database. I am using javascript to set the hidden input field values in a form.

    The problem is the selected ratings for each row must be sticky and stay selected to the new value. It works fine in Firefox but IE clears the previous selected values.

    What do I need to do to get my code to work in IE?

  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You've made an assumption about childNodes but browsers treat blank text in different ways. Some make them into nodes, others don't.
    Code:
    var current_rating = document.getElementById(f_id).childNodes[1];
    You can't rely on the above code catching the first li element.

    Try
    Code:
    var current_rating = document.getElementById(f_id).getElementsByTagName("li")[0];

  3. #3
    SitePoint Zealot ejg's Avatar
    Join Date
    Jun 2007
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you...that worked wonderfully.


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
  •