Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IE7 Crashes ith select box

    A problem with these code in IE7

    PHP Code:
    <select id="testSelect">
        <
    option value="one">1st option</option>
        <
    option value="two">2nd option</option>
    </
    select>

    <
    input type="button" value="remove" onclick="remove2()" />

    <
    script language="javascript">
        function 
    remove2(){
            
    selectBox document.getElementById("testSelect");
            if(
    selectBox.options.length 1) {            
                
    selectBox.remove(1);
            }
        }
    </script> 
    When :
    1. select option 2
    2. select option 1
    3. press remove button

    Internet Explorer 7 crashes without saying why.

  • #2
    Banned
    Join Date
    Nov 2008
    Location
    not found
    Posts
    284
    Thanks
    0
    Thanked 53 Times in 51 Posts
    Quote Originally Posted by edric View Post
    When :
    1. select option 2
    2. select option 1
    3. press remove button

    Internet Explorer 7 crashes without saying why.
    Unable to reproduce the problem.

    You can use selectBox.options[1]=null; but it should not make any difference.

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    1. language is deprecated. You should use type instead
    Code:
    script type="text/javascript">
    ...
    </script>
    Code:
    selectBox.remove(1);
    2. What do you intend to do with that remove() method/function/whichever?. Remove what?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm removing option in select box (it works the same as selectBox.options[1]=null)

    Its a very old code that needed a changed.
    I rewrite the code to use DOM objects (creating appending elements and nodes etc..) . so this solved.

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Like Kor I do not really understand what you are trying to do. Perhaps try this:-

    Code:
    <form name='myform'>
    <select name = 'list1' id = 'list1' onchange = "removeOptions(this)">
    <option selected value=""> Choose A Fruit</option>
    <option value='Mango'> Mango </option>
    <option value='Apple'> Apple </option>
    <option value='Orange'> Orange </option>
    <option value='Watermelon'> Watermelon </option>
    </select>
    </form>
    
    <script type = "text/javascript">
    var val = "";
    function removeOptions(selectbox) {
    val = selectbox.value;
    for (var i = selectbox.options.length-1; i>=1; i--) {
    if (selectbox.options[i].selected) {
    selectbox.remove(i);
    document.myform.list1.focus();
    }
    }
    }
    
    </script>
    "Funding is to be cut for sports where targets have been missed, such as archery". - Government spokesman

  • #6
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What don't you understand ?

    I found out element.removeChild(...) works better.
    Case Solved



    BTW: The IE Crash happens only if I try to remove second option out of two options.
    Last edited by edric; 07-21-2009 at 02:32 PM.


  •  

    Posting Permissions

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