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 Coder
    Join Date
    Nov 2009
    Posts
    16
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Internet Explorer Broken under new MSIE version

    The latest version of MSIE fails to read the value of a popup menu in a form that I have. It worked fine in a previous version, and works in Firefox and Mac Safari. Here is an edited version of what I have:
    Code:
    var d = null;
    
    function myTest(){
      alert("mWunits value = ".concat(d.mWunits.value))
    }
    .
    .
    .
    <body onload="d = document.forms[0];">
    .
    .
    .
    <form onsubmit="return false" >
      <table  align="center" border="0">
        <tbody>
          <tr>
            <td align="right">Conductor Size (d):</td>
            <td><input name="ef_dw" size="12"> </td>
            <td align="left">
              <select name="mWunits" size="1">
               <option selected="selected">mm</option>
               <option>AWG</option>
              </select>
            </td>
          </tr>
    .
    .
    .
    The popup name is mWunits, and should have either "AWG" or "mm" as a value. And the function myTest() should display that value. However the value is an empty string. There is another popup in the same form, and it exhibits the same problem. My script reads the values of regular input fields just fine. As I said, this used to work under earlier MSIE versions, and works in other browsers. Has something been deprecated that I don't know about?

  • #2
    New Coder
    Join Date
    Mar 2007
    Posts
    98
    Thanks
    24
    Thanked 4 Times in 4 Posts
    Try assigning values to the menu options:

    Code:
              <select name="mWunits" size="1">
               <option selected="selected" value="mm" >mm</option>
               <option value="AWG" >AWG</option>
              </select>

  • Users who have thanked longman for this post:

    BobW (12-21-2010)

  • #3
    New Coder
    Join Date
    Nov 2009
    Posts
    16
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Thanks. That fixed it. I'm confused though. According to the info I've read, if you don't explicitly assign a value, it should use the option element's contents by default. I guess I shouldn't take anything for granted.

    Also confusing: I have a similar form on another page, where the popups are nearly the same, but they work as intended. The only difference that I can see is that the working ones also have an onchange="doSomething()" function assigned, although the function doesn't set the value; it only reads it.

    Oh well, I guess from now on, I'll have to explicitly assign a value for each option.

  • #4
    New Coder
    Join Date
    Mar 2007
    Posts
    98
    Thanks
    24
    Thanked 4 Times in 4 Posts
    Glad it's sorted. As a general rule when working with IE, I never take anything for granted!

  • #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
    Quote Originally Posted by BobW View Post
    Oh well, I guess from now on, I'll have to explicitly assign a value for each option.
    In IE an option value must be assigned explicitly - the option text is not the value.


    Code:
    <select id = "mySelect" onchange = "getIt()">
      <option>Volvo</option>
      <option>Saab</option>
      <option>Mercedes</option>
      <option>Audi</option>
    </select> 
    
    
    <script type = "text/javascript">
    function getIt() {
    var val = document.getElementById("mySelect").value;
    alert (val);
    var si = document.getElementById("mySelect").selectedIndex;
    alert (si);
    var txt = document.getElementById("mySelect").options[si].text; 
    alert (txt);
    }
    </script>
    Last edited by Philip M; 12-21-2010 at 07:32 AM.

  • #6
    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
    Quote Originally Posted by BobW View Post
    I'm confused though. According to the info I've read, if you don't explicitly assign a value, it should use the option element's contents by default. I guess I shouldn't take anything for granted.
    It should. W3C Recommendations says so. But you should know, also, that MSIE does not follow always the W3C Recommendations, nor the ECMAScript standard.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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