onfocus for a <select>

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Berger

    #1

    onfocus for a <select>

    So, I'm fairly new to this and my code is as follows...

    <script language="JavaS cript>
    var oldValue

    function focusElement(th eElement) {
    oldValue = theElement.valu e;
    return;
    }
    </script>


    Then in the HTML, I have

    <select size="1" id="ConfComment SELECT" name="ConfComme ntSELECT"
    onfocus="return focusPrecedence (this);">
    <option value="0"> - </option>
    <option value="1">1</option>
    <option value="2">2</option>
    </select>

    The <select> is with a <form><tr><td >, but I don't see how that would make a
    difference. I started using the onchange="retur n blah-blah-blah(this);" and
    that worked so I copied that to the onfocus. What I want to do is to
    remember the value of the contents of the <select> before the user changes
    it, and compare it to the new value.

    However, I keep getting the following error
    A Runtime Error has occurred.
    Do you wish to Debug?

    Line:22
    Error: Object expected

    What am I doing wrong ?

    Thanks
    Mike




  • Mike Berger

    #2
    Re: onfocus for a &lt;select&g t;

    Okay, so I noticed my example code is wrong. The function called in my
    "onfocus=" line is really the correct function name. The function is named
    "focusEleme nt" and the "onfocus=" DOES call this same function.

    "Mike Berger" <mbergerREMOVET HIS@skypoint.co m> wrote in message
    news:vonsr97q6l fl09@corp.super news.com...[color=blue]
    > So, I'm fairly new to this and my code is as follows...
    >
    > <script language="JavaS cript>
    > var oldValue
    >
    > function focusElement(th eElement) {
    > oldValue = theElement.valu e;
    > return;
    > }
    > </script>
    >
    >
    > Then in the HTML, I have
    >
    > <select size="1" id="ConfComment SELECT" name="ConfComme ntSELECT"
    > onfocus="return focusPrecedence (this);">
    > <option value="0"> - </option>
    > <option value="1">1</option>
    > <option value="2">2</option>
    > </select>
    >
    > The <select> is with a <form><tr><td >, but I don't see how that would make[/color]
    a[color=blue]
    > difference. I started using the onchange="retur n blah-blah-blah(this);"[/color]
    and[color=blue]
    > that worked so I copied that to the onfocus. What I want to do is to
    > remember the value of the contents of the <select> before the user changes
    > it, and compare it to the new value.
    >
    > However, I keep getting the following error
    > A Runtime Error has occurred.
    > Do you wish to Debug?
    >
    > Line:22
    > Error: Object expected
    >
    > What am I doing wrong ?
    >
    > Thanks
    > Mike
    >
    >
    >
    >[/color]


    Comment

    • Mike Berger

      #3
      Re: onfocus for a &lt;select&g t;

      Okay, so they didn't have the same function name. Problem solved !!!

      "Mike Berger" <mbergerREMOVET HIS@skypoint.co m> wrote in message
      news:vonvvc8mmj 4s06@corp.super news.com...[color=blue]
      > Okay, so I noticed my example code is wrong. The function called in my
      > "onfocus=" line is really the correct function name. The function is named
      > "focusEleme nt" and the "onfocus=" DOES call this same function.
      >
      > "Mike Berger" <mbergerREMOVET HIS@skypoint.co m> wrote in message
      > news:vonsr97q6l fl09@corp.super news.com...[color=green]
      > > So, I'm fairly new to this and my code is as follows...
      > >
      > > <script language="JavaS cript>
      > > var oldValue
      > >
      > > function focusElement(th eElement) {
      > > oldValue = theElement.valu e;
      > > return;
      > > }
      > > </script>
      > >
      > >
      > > Then in the HTML, I have
      > >
      > > <select size="1" id="ConfComment SELECT" name="ConfComme ntSELECT"
      > > onfocus="return focusPrecedence (this);">
      > > <option value="0"> - </option>
      > > <option value="1">1</option>
      > > <option value="2">2</option>
      > > </select>
      > >
      > > The <select> is with a <form><tr><td >, but I don't see how that would[/color][/color]
      make[color=blue]
      > a[color=green]
      > > difference. I started using the onchange="retur n blah-blah-blah(this);"[/color]
      > and[color=green]
      > > that worked so I copied that to the onfocus. What I want to do is to
      > > remember the value of the contents of the <select> before the user[/color][/color]
      changes[color=blue][color=green]
      > > it, and compare it to the new value.
      > >
      > > However, I keep getting the following error
      > > A Runtime Error has occurred.
      > > Do you wish to Debug?
      > >
      > > Line:22
      > > Error: Object expected
      > >
      > > What am I doing wrong ?
      > >
      > > Thanks
      > > Mike
      > >
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...