SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Mar 2003
    Location
    In a house in the USA
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IE7 crashes with this jQuery code

    I have a page with 2 <select> drop down that when the top field changes the other is populated with new values. The problem is that in Vista Business IE7 crashes when you access the second select after setting the top select back to an option with an empty value. I am using jQuery 1.2.6 and jQuery Selectboxes 2.2.2 (from: http://www.texotela.co.uk/code/jquery/select/).

    The form:
    Code:
    <select id="AssetType" name="AssetType">
    <option value="">--Select--</option>
    <option value="1">Computer</option>
    </select>
    
    <select id="AssetTag" name="AssetTag">
    <option value="">--Select--</option>
    </select>
    The JS:
    Code:
    $("#AssetType").change(function() {
        var AssetType = $(this).selectedValues();
        if (AssetType == '') {
            $("#AssetTag").removeOption(/./);
        } else {
            $("#AssetTag").removeOption(/./).ajaxAddOption("/admin_v3/index.php/ajax/getassettags/"+AssetType, false, false);
        }
    });
    This code works fine in Firefox3 on Vista but not IE. I checked the code while logged into a Windows 2k3 terminal server and everything was fine there.

    Any ideas?
    Daniel
    http://www.wlscripting.com - PHP Tutorials and code snippets
    Notepad++ Function List plugin tip - for PHP developers

  2. #2
    SitePoint Addict
    Join Date
    Mar 2003
    Location
    In a house in the USA
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have also just tried using something other than the jquery select plugin and did with the following code and it still crashes.

    Code:
    $("select#AssetType").change(function(){
            var AssetType = $(this).val();
            var options = '<option value="">--Select--</option>';
            $.getJSON("/admin_v3/index.php/ajax/getassettags/"+AssetType, { }, function(data){
                $.each(data.Assets, function(i, asset) {
                    options += '<option value="'+data.AssetType+'-'+asset.AssetID+'">'+asset.AssetTag+'</option>';
                });
                $("select#AssetTag").html(options);
            })
      });
    I have used Firebug to watch the modification of the source in Firefox and everything syntax wise looks fine.

    I have tried to modify the following:
    1. Check my Doctype to ensure that it was correct
    2. Added a 0 value to the default select options to rule out needing a value in the select

    Any suggestions? Could somebody try this on their Vista machine so I can find out if it is just my machine?
    Daniel
    http://www.wlscripting.com - PHP Tutorials and code snippets
    Notepad++ Function List plugin tip - for PHP developers


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
  •