IE won't see <SELECT> fields

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    #1

    IE won't see <SELECT> fields

    I can't get IE 6 to read the values in my <SELECT..> data entry fields.
    Netscape 7 and Opera see them, and IE will pass the values to the
    database, but the javascript validation script gets a null value from
    the selection fields. Text inputs work just fine.

    Below is the form and validation script (I've added "...." to indicate
    additional fields in the same format in both the form and the
    validation)

    Here's the form:
    <FORM NAME="LibrarySu rvey" ACTION="FMPro" METHOD="Post" onSubmit="retur n
    Validate(this)" >
    <INPUT TYPE="hidden" NAME="-db" VALUE="LibraryS urvey.fp5">
    <INPUT TYPE="hidden" NAME="-lay" VALUE="Master">
    <INPUT TYPE="hidden" NAME="-format" VALUE="LS_ok.ht m">

    <br>
    <TABLE border = "0" width = "75%">
    <TH COLSPAN= "3" ALIGN="center" BGCOLOR="#CC99F F"><STRONG>LIBR ARY SURVEY
    </STRONG></TH>

    <COLGROUP span = "3" RULES = "rows">
    <COL span "1" width = 48% VALIGN = top ></COL>
    <COL span "2" align = "right" width = 2% ></COL>
    <COL span "3" width = 50% VALIGN = top ></COL>
    </COLGROUP>
    <TR>
    <TD>Librarian Name </TD>
    <TD></TD>
    <TD>
    <INPUT TYPE="hidden" NAME="Librarian Name" VALUE= "">
    </TD>
    </TR>
    <TR>
    <TD>Building </TD>
    <TD></TD>
    <TD>
    <INPUT TYPE="hidden" NAME="SchoolNam e" VALUE="">
    </TD>
    </TR>
    <TR>
    <TD>Date of Request</TD>
    <TD></TD>
    <TD>
    <INPUT TYPE="text" NAME="RequestDa te" VALUE="">
    </TD>
    </TR>
    <TR>
    <TD>Time of Request</TD>
    <TD></TD>
    <TD>
    <SELECT NAME="RequestTi me">
    <OPTION></OPTION>
    <OPTION>7am</OPTION>
    <OPTION>8am</OPTION>
    <OPTION>9am</OPTION>
    <OPTION>10am</OPTION>
    <OPTION>11am</OPTION>
    <OPTION>12pm</OPTION>
    <OPTION>1pm</OPTION>
    <OPTION>2pm</OPTION>
    <OPTION>3pm</OPTION>
    <OPTION>4pm</OPTION>
    <OPTION>5pm</OPTION>
    <OPTION>6pm</OPTION>
    <OPTION>7pm</OPTION>
    <OPTION>other </OPTION>
    </SELECT>

    </TD>
    </TR>
    <TR>
    <TD>Date of Service
    </TD>
    <TD></TD>
    <TD>
    <INPUT TYPE="text" NAME="ServiceDa te" VALUE="" >
    </TD>
    </TR>
    <TR>
    <TD>Time of Service </TD>
    <TD></TD>
    <TD>
    <SELECT NAME="ServiceTi me">
    <OPTION></OPTION>
    <OPTION>7am</OPTION>
    <OPTION>8am</OPTION>
    <OPTION>9am</OPTION>
    <OPTION>10am</OPTION>
    <OPTION>11am</OPTION>
    <OPTION>12pm</OPTION>
    <OPTION>1pm</OPTION>
    <OPTION>2pm</OPTION>
    <OPTION>3pm</OPTION>
    <OPTION>4pm</OPTION>
    <OPTION>5pm</OPTION>
    <OPTION>6pm</OPTION>
    <OPTION>7pm</OPTION>
    <OPTION>other </OPTION>
    </SELECT>

    </TD>
    </TR>
    <TR>
    <TD> Your total time on the problem </TD>
    <TD></TD>
    <TD>
    <SELECT Name="ServiceDu ration">
    <OPTION></OPTION>
    <OPTION>1-5 minutes </OPTION>
    <OPTION>6-15 minutes </OPTION>
    <OPTION>16-30 minutes </OPTION>
    <OPTION>31-60 minutes </OPTION>
    <OPTION>Over 60 minutes </OPTION>
    </SELECT>
    </TD>
    </TR>

    .....

    </TABLE>

    </FORM>

    _______________ _______________ _______________ _______________ ____
    _______________ _______________ _______________ _______________ ____

    And the validation function (in the header):

    <SCRIPT LANGUAGE = "Javascript 1.3" type="text/javascript">
    function Validate(f)
    {

    var mdy = new Date;
    alert (f.RequestTime. value)
    alert (f.RequestDate. value)
    if (f.RequestDate. value=="")
    {
    alert("Date of Request is Required")
    f.RequestDate.f ocus();return false
    }


    if (f.RequestTime. value=="")
    {
    alert("Please enter the time the request was made." )
    f.RequestTime.f ocus();return false
    }
    .....

    }
    </SCRIPT>
  • Mick White

    #2
    Re: IE won't see &lt;SELECT&g t; fields

    tac700@cornell. edu wrote:
    [color=blue]
    > I can't get IE 6 to read the values in my <SELECT..> data entry fields.
    > Netscape 7 and Opera see them, and IE will pass the values to the
    > database, but the javascript validation script gets a null value from
    > the selection fields. Text inputs work just fine.[/color]

    [snip]

    [color=blue]
    > <SELECT NAME="RequestTi me">
    > <OPTION></OPTION>
    > <OPTION>7am</OPTION>
    > <OPTION>8am</OPTION>
    > <OPTION>9am</OPTION>
    > <OPTION>10am</OPTION>
    > <OPTION>11am</OPTION>
    > <OPTION>12pm</OPTION>
    > <OPTION>1pm</OPTION>
    > <OPTION>2pm</OPTION>
    > <OPTION>3pm</OPTION>
    > <OPTION>4pm</OPTION>
    > <OPTION>5pm</OPTION>
    > <OPTION>6pm</OPTION>
    > <OPTION>7pm</OPTION>
    > <OPTION>other </OPTION>
    > </SELECT>[/color]

    The select object options don't have any values.

    <OPTION>7am</OPTION> // No value

    <OPTION value="7am">7am </OPTION> // This has a value

    [color=blue]
    >
    > <SCRIPT LANGUAGE = "Javascript 1.3" type="text/javascript">[/color]

    <SCRIPT type="text/javascript">
    [color=blue]
    > function Validate(f)
    > {
    >
    > var mdy = new Date;
    > alert (f.RequestTime. value)[/color]

    alert(f.request Date.options[f.RequestDate.o ptions.selected Index].text)

    This is a cross browser and unambiguous way to reference the text(not
    the value)that the user has chosen.
    [color=blue]
    > alert (f.RequestDate. value)
    > if (f.RequestDate. value=="")[/color]

    if (f.RequestDate. value=="") //always false in your case, try:

    if(f.RequestDat e.selectedIndex <1)

    [snip]

    Mick

    Comment

    • Michael Winter

      #3
      Re: IE won't see &lt;SELECT&g t; fields

      On Mon, 24 Jan 2005 19:15:49 GMT, Mick White
      <mwhite13BOGUS@ rochester.rr.co m> wrote:

      [snip]
      [color=blue]
      > The select object options don't have any values.
      >
      > <OPTION>7am</OPTION> // No value[/color]

      That is incorrect. If a user agent follows the prose of the HTML
      specification, it will use the content of the element as the initial value:

      "Note that where the value attribute is set, it determines the
      control's initial value, otherwise it's the element's contents."

      Other browsers do this. IE doesn't.

      [snip]

      Mike

      --
      Michael Winter
      Replace ".invalid" with ".uk" to reply by e-mail.

      Comment

      • Guest's Avatar

        #4
        Re: IE won't see &lt;SELECT&g t; fields: thank you

        Thanks Mick, Michael..

        Mick's solution made the problem go away. -tc

        In article <opsk4gpja5x13k vk@atlantis>, M.Winter@blueyo nder.co.invalid
        says...[color=blue]
        > On Mon, 24 Jan 2005 19:15:49 GMT, Mick White
        > <mwhite13BOGUS@ rochester.rr.co m> wrote:
        >
        > [snip]
        >[color=green]
        > > The select object options don't have any values.
        > >
        > > <OPTION>7am</OPTION> // No value[/color]
        >
        > That is incorrect. If a user agent follows the prose of the HTML
        > specification, it will use the content of the element as the initial value:
        >
        > "Note that where the value attribute is set, it determines the
        > control's initial value, otherwise it's the element's contents."
        >
        > Other browsers do this. IE doesn't.
        >
        > [snip]
        >
        > Mike
        >
        >[/color]

        Comment

        • Mick White

          #5
          Re: IE won't see &lt;SELECT&g t; fields

          Michael Winter wrote:
          [color=blue]
          >
          > That is incorrect. If a user agent follows the prose of the HTML
          > specification, it will use the content of the element as the initial value:
          >
          > "Note that where the value attribute is set, it determines the
          > control's initial value, otherwise it's the element's contents."
          >
          > Other browsers do this. IE doesn't.
          >[/color]



          "Note: The <option> tag can be used without any attributes, but you
          usually need the value attribute, which indicates what is sent to the
          server."

          Ambiguous, perhaps?
          Mick

          Comment

          • Mick White

            #6
            Re: IE won't see &lt;SELECT&g t; fields

            Mick White wrote:
            [color=blue]
            >
            > http://www.w3schools.com/tags/tag_option.asp
            >
            > "Note: The <option> tag can be used without any attributes,
            > but you usually need the value attribute, which indicates what
            > is sent to the server."[/color]


            "Note: The <option> tag can be used without any attributes, but you
            usually need the value attribute, which indicates what is sent to the
            server."

            Surry about the formatting.
            Mick

            Comment

            • Michael Winter

              #7
              Re: IE won't see &lt;SELECT&g t; fields

              On Mon, 24 Jan 2005 22:11:04 GMT, Mick White
              <mwhite13BOGUS@ rochester.rr.co m> wrote:

              [snip]
              [color=blue]
              > http://www.w3schools.com/tags/tag_option.asp[/color]

              [snip]
              [color=blue]
              > Ambiguous, perhaps?[/color]

              What does it matter? W3Schools have no authority and the specification is
              clear (see
              <URL:http://www.w3.org/TR/html4/interact/forms.html#adef-value-OPTION>).

              However, if you're working with IE and you need to access the value
              programmaticall y[1], you will always have to explicitly provide it in the
              mark-up.

              Mike


              [1] IE does seems to conform to specification when submitting to the
              server, though.

              --
              Michael Winter
              Replace ".invalid" with ".uk" to reply by e-mail.

              Comment

              • Grant Wagner

                #8
                Re: IE won't see &lt;SELECT&g t; fields

                "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message
                news:opsk4pu8k4 x13kvk@atlantis ...[color=blue]
                > On Mon, 24 Jan 2005 22:11:04 GMT, Mick White
                > <mwhite13BOGUS@ rochester.rr.co m> wrote:
                >
                > [snip]
                >[color=green]
                >> http://www.w3schools.com/tags/tag_option.asp[/color]
                >
                > [snip]
                >[color=green]
                >> Ambiguous, perhaps?[/color]
                >
                > What does it matter? W3Schools have no authority and the specification
                > is clear (see
                > <URL:http://www.w3.org/TR/html4/interact/forms.html#adef-value-OPTION>).
                >
                > However, if you're working with IE and you need to access the value
                > programmaticall y[1], you will always have to explicitly provide it in
                > the mark-up.
                >
                > Mike
                >
                >
                > [1] IE does seems to conform to specification when submitting to the
                > server, though.[/color]

                Or if you are concerned about the weight of "doubling up" the <option>
                text and value attributes, you could use a function like the following
                as part of the onload event of your page:

                function setOptionValues ()
                {
                var ii = document.forms. length;
                while (ii-- > 0)
                {
                var f = document.forms[ii];
                if (!f || !(f = f.elements))
                {
                continue;
                }

                var jj = +f.length || 0;
                while (jj-- > 0)
                {
                var sel = f[jj];
                if (!sel || !/^select/.test(sel.type) || !(sel =
                sel.options))
                {
                continue;
                }

                var kk = +sel.length || 0;
                while (kk-- > 0)
                {
                if ("" == sel[kk].value)
                {
                sel[kk].value = sel[kk].text;
                }
                }
                }
                }
                }

                --
                Grant Wagner <gwagner@agrico reunited.com>
                comp.lang.javas cript FAQ - http://jibbering.com/faq


                Comment

                Working...