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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2008
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Accessing Objects in IE6 and IE7

    Hi

    I have problem with accessing objects in IE7 while in IE6 everything works fine.

    Following code works fine with IE6. The value of the element (dropdown list) is accessed correctly and the value of each selected option is correctly writen on the page.
    In IE7 the value of first option is writen on the page and it will not change when I select another option from dropdown list.

    This does not work even with getElementById.

    Code:
    <script language=javascript>
    document.write("<form name='selection'>Select:");
    document.write("<select name='SEL' onchange='history.go(0)'>");
    document.write("<option value=1>400</option>");
    document.write("<option value=2>500</option>");
    document.write("<option value=3>600</option>");
    document.write("</select></form>");
    document.write(document.selection.SEL.value);
    </script>
    Can someone pls help to bring a light into this.

    Thx

    Nevo
    Last edited by Nevo; 06-08-2008 at 06:15 PM.

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by Nevo View Post
    Code:
    document.write("<select name='SEL' onchange='history.go(0)'>");
    Whenever you change the option you call history.go(0), which will reload the page.
    What do you expect to happen?

  • #3
    New to the CF scene
    Join Date
    May 2008
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thx for input.
    Yes, I know. But the weird thing is that it works in IE6 and Firefox.
    You can try it. All the time when you make the selection and the page is reloaded the value changes. This is not true in IE7.

    In IE7 I need to call function and put the value somewhere - e.g. using innerHTML.
    I mean it works for IE7 only this way (all what I found out yet):

    Code:
    <script language=javascript>
    document.write("<form name='selection'>Select:");
    document.write("<select id='SEL' onchange='Fnc()'>");
    document.write("<option value=1>400</option>");
    document.write("<option value=2>500</option>");
    document.write("<option value=3>600</option>");
    document.write("</select></form>");
    
    function Fnc(){
    var sel=document.getElementById('SEL');
    document.getElementById('p')innerHTML=sel.value;
    }
    </script>
    
    <p id='p'></p>
    I need this functionality but without calling function. Can this be done in IE7?

    Thx for any advice.

    Nevo

  • #4
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by Nevo View Post
    I need this functionality but without calling function. Can this be done in IE7?
    Reloading a page and expecting an element's value to be preserved is inadvisable.
    Your way is acceptable and there's no way to do it without calling some function.


  •  

    Posting Permissions

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