Reassigning event handler

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

    Reassigning event handler

    I'm using the code shown below which displays 3 input fields - when you
    click on an input field, a DIV is displayed which allows you to select a
    task. On clicking the task, it is inserted into the appropriate input field,
    and the DIV is hidden again.

    I'm using a tooltip script from Dynamic Drive (ommitted for clarity) to show
    the task description over the input field, but I am unable to reassign a new
    function to the onmouseover event handler of the input field using ...

    document.forms["timesheet"].elements[fld].onmouseover=dd rive(tip,300);

    Can anyone tell me why this doesn't work (and how to make it work!)?

    -----------------------------------------
    Rae MacLeman
    info@cobwebbery .co.uk
    Cobwebbery Web Design

    =============== =============== =============== ==========
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>
    <head>
    <title>Timeshee t Data Capture Demo</title>
    <script language="JavaS cript" type="text/javascript">
    <!--
    var fld = '';

    function setFld(f){
    fld = f;
    }
    function setTip(fld,tip) {
    document.forms["timesheet"].elements[fld].onmouseover=dd rive(tip,300);
    }
    -->
    </script>

    </head>

    <body>

    <!-- Create the task picker -->
    <div id="picker" style="border: 1px solid red; background-color: #F0F8FF;
    padding: 5px; width:260px; visibility: hidden;">
    <span style="cursor: hand;"
    onclick="docume nt.getElementBy Id(fld).value=' Task001';docume nt.getElementBy I
    d('picker').sty le.visibility=' hidden';setTip( fld,'Overhaul brakes');">Task
    001 - Overhaul braking system</span><br>
    <span style="cursor: hand;"
    onclick="docume nt.getElementBy Id(fld).value=' Task002';docume nt.getElementBy I
    d('picker').sty le.visibility=' hidden';">Task 002 - Full service up to
    1000cc</span><br>
    <span style="cursor: hand;"
    onclick="docume nt.getElementBy Id(fld).value=' Task003';docume nt.getElementBy I
    d('picker').sty le.visibility=' hidden';">Task 003 - Full service
    1001-2000cc</span><br>
    <span style="cursor: hand;"
    onclick="docume nt.getElementBy Id(fld).value=' Task004';docume nt.getElementBy I
    d('picker').sty le.visibility=' hidden';">Task 004 - Camshaft
    replacement</span><br>
    </div>

    <!-- The data capture form -->
    <form action="" name="timesheet " id="timesheet" >
    <input onMouseover="dd rivetip('unavai lable', 300)";
    onMouseout="hid eddrivetip()" style="cursor:h elp;" type="text" name="task1"
    id="task1"
    onclick="setFld ('task1');docum ent.getElementB yId('picker').s tyle.visibility =
    'visible';"><br >
    <input style="cursor:h elp;" type="text" name="task2" id="task2"
    onclick="setFld ('task2');docum ent.getElementB yId('picker').s tyle.visibility =
    'visible';"><br >
    <input style="cursor:h elp;" type="text" name="task3" id="task3"
    onclick="setFld ('task3');docum ent.getElementB yId('picker').s tyle.visibility =
    'visible';"><br >
    </form>

    </body>
    </html>

    --





    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.794 / Virus Database: 538 - Release Date: 11/10/04


  • RobB

    #2
    Re: Reassigning event handler

    "webdev" <someone@micros ofdt.com> wrote in message news:<110027304 8.10970.0@doris .uk.clara.net>. ..[color=blue]
    > I'm using the code shown below which displays 3 input fields - when you
    > click on an input field, a DIV is displayed which allows you to select a
    > task. On clicking the task, it is inserted into the appropriate input field,
    > and the DIV is hidden again.
    >
    > I'm using a tooltip script from Dynamic Drive (ommitted for clarity) to show
    > the task description over the input field, but I am unable to reassign a new
    > function to the onmouseover event handler of the input field using ...
    >
    > document.forms["timesheet"].elements[fld].onmouseover=dd rive(tip,300);
    >
    > Can anyone tell me why this doesn't work (and how to make it work!)?
    >
    > -----------------------------------------
    > Rae MacLeman
    > info@cobwebbery .co.uk
    > Cobwebbery Web Design
    >
    > =============== =============== =============== ==========
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    >
    > <html>
    > <head>
    > <title>Timeshee t Data Capture Demo</title>
    > <script language="JavaS cript" type="text/javascript">
    > <!--
    > var fld = '';
    >
    > function setFld(f){
    > fld = f;
    > }
    > function setTip(fld,tip) {
    > document.forms["timesheet"].elements[fld].onmouseover=dd rive(tip,300);
    > }
    > -->
    > </script>
    >
    > </head>
    >
    > <body>
    >
    > <!-- Create the task picker -->
    > <div id="picker" style="border: 1px solid red; background-color: #F0F8FF;
    > padding: 5px; width:260px; visibility: hidden;">
    > <span style="cursor: hand;"
    > onclick="docume nt.getElementBy Id(fld).value=' Task001';docume nt.getElementBy I
    > d('picker').sty le.visibility=' hidden';setTip( fld,'Overhaul brakes');">Task
    > 001 - Overhaul braking system</span><br>
    > <span style="cursor: hand;"
    > onclick="docume nt.getElementBy Id(fld).value=' Task002';docume nt.getElementBy I
    > d('picker').sty le.visibility=' hidden';">Task 002 - Full service up to
    > 1000cc</span><br>
    > <span style="cursor: hand;"
    > onclick="docume nt.getElementBy Id(fld).value=' Task003';docume nt.getElementBy I
    > d('picker').sty le.visibility=' hidden';">Task 003 - Full service
    > 1001-2000cc</span><br>
    > <span style="cursor: hand;"
    > onclick="docume nt.getElementBy Id(fld).value=' Task004';docume nt.getElementBy I
    > d('picker').sty le.visibility=' hidden';">Task 004 - Camshaft
    > replacement</span><br>
    > </div>
    >
    > <!-- The data capture form -->
    > <form action="" name="timesheet " id="timesheet" >
    > <input onMouseover="dd rivetip('unavai lable', 300)";
    > onMouseout="hid eddrivetip()" style="cursor:h elp;" type="text" name="task1"
    > id="task1"
    > onclick="setFld ('task1');docum ent.getElementB yId('picker').s tyle.visibility =
    > 'visible';"><br >
    > <input style="cursor:h elp;" type="text" name="task2" id="task2"
    > onclick="setFld ('task2');docum ent.getElementB yId('picker').s tyle.visibility =
    > 'visible';"><br >
    > <input style="cursor:h elp;" type="text" name="task3" id="task3"
    > onclick="setFld ('task3');docum ent.getElementB yId('picker').s tyle.visibility =
    > 'visible';"><br >
    > </form>
    >
    > </body>
    > </html>
    >
    > --
    >
    >
    >
    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system (http://www.grisoft.com).
    > Version: 6.0.794 / Virus Database: 538 - Release Date: 11/10/04[/color]


    Should really use document.getEle mentById()...

    document.forms["timesheet"].elements[fld].onmouseover= function()
    {
    ddrive(tip,300) ;
    }

    Don't want the handler called while assigning.

    Comment

    • webdev

      #3
      Re: Reassigning event handler


      "RobB" <ferndoc9@hotma il.com> wrote in message
      news:ab354593.0 411121144.48b5a d69@posting.goo gle.com...[color=blue]
      > "webdev" <someone@micros ofdt.com> wrote in message[/color]
      news:<110027304 8.10970.0@doris .uk.clara.net>. ..[color=blue][color=green]
      > > I'm using the code shown below which displays 3 input fields - when you
      > > click on an input field, a DIV is displayed which allows you to select a
      > > task. On clicking the task, it is inserted into the appropriate input[/color][/color]
      field,[color=blue][color=green]
      > > and the DIV is hidden again.
      > >
      > > I'm using a tooltip script from Dynamic Drive (ommitted for clarity) to[/color][/color]
      show[color=blue][color=green]
      > > the task description over the input field, but I am unable to reassign a[/color][/color]
      new[color=blue][color=green]
      > > function to the onmouseover event handler of the input field using ...
      > >
      > >[/color][/color]
      document.forms["timesheet"].elements[fld].onmouseover=dd rive(tip,300);[color=blue][color=green]
      > >
      > > Can anyone tell me why this doesn't work (and how to make it work!)?
      > >
      > > -----------------------------------------
      > > Rae MacLeman
      > > info@cobwebbery .co.uk
      > > Cobwebbery Web Design
      > >[/color][/color]
      [ === SCRIPT REMOVED ===][color=blue][color=green]
      > >
      > > ---
      > > Outgoing mail is certified Virus Free.
      > > Checked by AVG anti-virus system (http://www.grisoft.com).
      > > Version: 6.0.794 / Virus Database: 538 - Release Date: 11/10/04[/color]
      >
      >
      > Should really use document.getEle mentById()...
      >
      > document.forms["timesheet"].elements[fld].onmouseover= function()
      > {
      > ddrive(tip,300) ;
      > }
      >
      > Don't want the handler called while assigning.[/color]


      Works now. many thanks RobB!




      ---
      Outgoing mail is certified Virus Free.
      Checked by AVG anti-virus system (http://www.grisoft.com).
      Version: 6.0.794 / Virus Database: 538 - Release Date: 11/10/04


      Comment

      Working...