onClick onUnClick ???

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

    onClick onUnClick ???

    The code shown below displays a table in a form with 3 check boxes.
    When the left checkbox is selected, all other checkboxes are also
    selected (hotmail style) (thanks for the groups help with this). The
    onUnCick event doesn't work. Could anyone tell me how to correct it??

    Thanks,

    Ed



    <html>
    <head>
    <title></title>
    </head>
    <body>

    <form name=taskform action=test.php method=post>

    <script language="JavaS cript">
    <!--
    var row_1 = new Array("Monday0" , "Monday1")
    function check_boxes1(st ate)
    {
    for (y=0; y < row_1.length; y++)
    {
    for (i = 0; i < document.taskfo rm.elements.len gth; i++)
    {
    if (document.taskf orm.elements[i].name == row_1[y])
    document.taskfo rm.elements[i].checked = state;
    }
    }
    }
    --> </script>

    <table border=1 width=85%>
    <tr>
    <td class=small>Che ck increment</td>
    <td class=small>tog gle</td>
    <td class=small>0:0 0</td><td class=small>1:0 0</td>
    </tr>
    <tr>
    <td class=small>on the hour</td>
    <td><input type=checkbox name=checkall_r ow1
    onClick="check_ boxes1(true)" onUnClick="chec k_boxes1(false) "></td>
    <td><input type=checkbox name=Monday0></td>
    <td><input type=checkbox name=Monday1></td>
    </tr>
    </table>


    </form>
    </body>
    </html>
  • McKirahan

    #2
    Re: onClick onUnClick ???

    "Edward" <egoduk@hotmail .com> wrote in message
    news:587a2724.0 312270614.2915a 0e7@posting.goo gle.com...[color=blue]
    > The code shown below displays a table in a form with 3 check boxes.
    > When the left checkbox is selected, all other checkboxes are also
    > selected (hotmail style) (thanks for the groups help with this). The
    > onUnCick event doesn't work. Could anyone tell me how to correct it??
    >
    > Thanks,
    >
    > Ed
    >
    >
    >
    > <html>
    > <head>
    > <title></title>
    > </head>
    > <body>
    >
    > <form name=taskform action=test.php method=post>
    >
    > <script language="JavaS cript">
    > <!--
    > var row_1 = new Array("Monday0" , "Monday1")
    > function check_boxes1(st ate)
    > {
    > for (y=0; y < row_1.length; y++)
    > {
    > for (i = 0; i < document.taskfo rm.elements.len gth; i++)
    > {
    > if (document.taskf orm.elements[i].name == row_1[y])
    > document.taskfo rm.elements[i].checked = state;
    > }
    > }
    > }
    > --> </script>
    >
    > <table border=1 width=85%>
    > <tr>
    > <td class=small>Che ck increment</td>
    > <td class=small>tog gle</td>
    > <td class=small>0:0 0</td><td class=small>1:0 0</td>
    > </tr>
    > <tr>
    > <td class=small>on the hour</td>
    > <td><input type=checkbox name=checkall_r ow1
    > onClick="check_ boxes1(true)" onUnClick="chec k_boxes1(false) "></td>
    > <td><input type=checkbox name=Monday0></td>
    > <td><input type=checkbox name=Monday1></td>
    > </tr>
    > </table>
    >
    >
    > </form>
    > </body>
    > </html>[/color]


    There is no "onUnClick" event!

    You'll have to test (in your JavaScript) whether or not the checkbox is
    checked.

    If it's no longer checked then treat it as an "UnClick".


    Comment

    • McKirahan

      #3
      Re: onClick onUnClick ???

      "McKirahan" <News@McKirahan .com> wrote in message
      news:qBgHb.4931 18$275.1390053@ attbi_s53...[color=blue]
      > "Edward" <egoduk@hotmail .com> wrote in message
      > news:587a2724.0 312270614.2915a 0e7@posting.goo gle.com...[color=green]
      > > The code shown below displays a table in a form with 3 check boxes.
      > > When the left checkbox is selected, all other checkboxes are also
      > > selected (hotmail style) (thanks for the groups help with this). The
      > > onUnCick event doesn't work. Could anyone tell me how to correct it??
      > >
      > > Thanks,
      > >
      > > Ed
      > >
      > >
      > >
      > > <html>
      > > <head>
      > > <title></title>
      > > </head>
      > > <body>
      > >
      > > <form name=taskform action=test.php method=post>
      > >
      > > <script language="JavaS cript">
      > > <!--
      > > var row_1 = new Array("Monday0" , "Monday1")
      > > function check_boxes1(st ate)
      > > {
      > > for (y=0; y < row_1.length; y++)
      > > {
      > > for (i = 0; i < document.taskfo rm.elements.len gth; i++)
      > > {
      > > if (document.taskf orm.elements[i].name == row_1[y])
      > > document.taskfo rm.elements[i].checked = state;
      > > }
      > > }
      > > }
      > > --> </script>
      > >
      > > <table border=1 width=85%>
      > > <tr>
      > > <td class=small>Che ck increment</td>
      > > <td class=small>tog gle</td>
      > > <td class=small>0:0 0</td><td class=small>1:0 0</td>
      > > </tr>
      > > <tr>
      > > <td class=small>on the hour</td>
      > > <td><input type=checkbox name=checkall_r ow1
      > > onClick="check_ boxes1(true)" onUnClick="chec k_boxes1(false) "></td>
      > > <td><input type=checkbox name=Monday0></td>
      > > <td><input type=checkbox name=Monday1></td>
      > > </tr>
      > > </table>
      > >
      > >
      > > </form>
      > > </body>
      > > </html>[/color]
      >
      >
      > There is no "onUnClick" event!
      >
      > You'll have to test (in your JavaScript) whether or not the checkbox is
      > checked.
      >
      > If it's no longer checked then treat it as an "UnClick".[/color]


      This variation of your code does what you want; watch for word-wrap:


      <html>
      <head>
      <title>unclicks .htm</title>
      <script language="JavaS cript" type="text/lanaguage">
      <!--
      var row_1 = new Array("Monday0" , "Monday1")
      function check_boxes1() {
      var form = document.taskfo rm;
      var state = false;
      if (form.checkall_ row1.checked) state = true;
      for (y=0; y < row_1.length; y++) {
      for (i = 0; i < form.elements.l ength; i++) {
      if (form.elements[i].name == row_1[y])
      form.elements[i].checked = state;
      }
      }
      }
      -->
      </script>
      </head>
      <body>
      <form name="taskform" action="test.ph p" method="post">
      <table border="1" width="85%">
      <tr>
      <td class="small">C heck increment</td>
      <td class="small">t oggle</td>
      <td class="small">0 :00</td>
      <td class="small">1 :00</td>
      </tr>
      <tr>
      <td class=small>on the hour</td>
      <td><input type="checkbox" name="checkall_ row1"
      onClick="check_ boxes1()"></td>
      <td><input type="checkbox" name="Monday0"> </td>
      <td><input type="checkbox" name="Monday1"> </td>
      </tr>
      </table>
      </form>
      </body>
      </html>


      Note that I:
      a) relocated the <script> within the <head> tags;
      b) inserted type="text/lanaguage";
      c) declare "var form = document.taskfo rm;";
      d) enclosed values (after "=") in quotes.

      I have a habit of cleaning up other's code to my conventions...


      Comment

      • McKirahan

        #4
        Re: onClick onUnClick ???

        "McKirahan" <News@McKirahan .com> wrote in message
        news:fMgHb.5422 0$VB2.95096@att bi_s51...[color=blue]
        > "McKirahan" <News@McKirahan .com> wrote in message
        > news:qBgHb.4931 18$275.1390053@ attbi_s53...[color=green]
        > > "Edward" <egoduk@hotmail .com> wrote in message
        > > news:587a2724.0 312270614.2915a 0e7@posting.goo gle.com...[color=darkred]
        > > > The code shown below displays a table in a form with 3 check boxes.
        > > > When the left checkbox is selected, all other checkboxes are also
        > > > selected (hotmail style) (thanks for the groups help with this). The
        > > > onUnCick event doesn't work. Could anyone tell me how to correct it??
        > > >
        > > > Thanks,
        > > >
        > > > Ed
        > > >
        > > >
        > > >
        > > > <html>
        > > > <head>
        > > > <title></title>
        > > > </head>
        > > > <body>
        > > >
        > > > <form name=taskform action=test.php method=post>
        > > >
        > > > <script language="JavaS cript">
        > > > <!--
        > > > var row_1 = new Array("Monday0" , "Monday1")
        > > > function check_boxes1(st ate)
        > > > {
        > > > for (y=0; y < row_1.length; y++)
        > > > {
        > > > for (i = 0; i < document.taskfo rm.elements.len gth; i++)
        > > > {
        > > > if (document.taskf orm.elements[i].name == row_1[y])
        > > > document.taskfo rm.elements[i].checked = state;
        > > > }
        > > > }
        > > > }
        > > > --> </script>
        > > >
        > > > <table border=1 width=85%>
        > > > <tr>
        > > > <td class=small>Che ck increment</td>
        > > > <td class=small>tog gle</td>
        > > > <td class=small>0:0 0</td><td class=small>1:0 0</td>
        > > > </tr>
        > > > <tr>
        > > > <td class=small>on the hour</td>
        > > > <td><input type=checkbox name=checkall_r ow1
        > > > onClick="check_ boxes1(true)" onUnClick="chec k_boxes1(false) "></td>
        > > > <td><input type=checkbox name=Monday0></td>
        > > > <td><input type=checkbox name=Monday1></td>
        > > > </tr>
        > > > </table>
        > > >
        > > >
        > > > </form>
        > > > </body>
        > > > </html>[/color]
        > >
        > >
        > > There is no "onUnClick" event!
        > >
        > > You'll have to test (in your JavaScript) whether or not the checkbox is
        > > checked.
        > >
        > > If it's no longer checked then treat it as an "UnClick".[/color]
        >
        >
        > This variation of your code does what you want; watch for word-wrap:
        >
        >
        > <html>
        > <head>
        > <title>unclicks .htm</title>
        > <script language="JavaS cript" type="text/lanaguage">
        > <!--
        > var row_1 = new Array("Monday0" , "Monday1")
        > function check_boxes1() {
        > var form = document.taskfo rm;
        > var state = false;
        > if (form.checkall_ row1.checked) state = true;
        > for (y=0; y < row_1.length; y++) {
        > for (i = 0; i < form.elements.l ength; i++) {
        > if (form.elements[i].name == row_1[y])
        > form.elements[i].checked = state;
        > }
        > }
        > }
        > -->
        > </script>
        > </head>
        > <body>
        > <form name="taskform" action="test.ph p" method="post">
        > <table border="1" width="85%">
        > <tr>
        > <td class="small">C heck increment</td>
        > <td class="small">t oggle</td>
        > <td class="small">0 :00</td>
        > <td class="small">1 :00</td>
        > </tr>
        > <tr>
        > <td class=small>on the hour</td>
        > <td><input type="checkbox" name="checkall_ row1"
        > onClick="check_ boxes1()"></td>
        > <td><input type="checkbox" name="Monday0"> </td>
        > <td><input type="checkbox" name="Monday1"> </td>
        > </tr>
        > </table>
        > </form>
        > </body>
        > </html>
        >
        >
        > Note that I:
        > a) relocated the <script> within the <head> tags;
        > b) inserted type="text/lanaguage";
        > c) declare "var form = document.taskfo rm;";
        > d) enclosed values (after "=") in quotes.
        >
        > I have a habit of cleaning up other's code to my conventions...[/color]


        Oops!

        Change
        type="text/lanaguage"
        to
        type="text/javascript"


        Comment

        • HikksNotAtHome

          #5
          Re: onClick onUnClick ???

          In article <PTgHb.149595$8 y1.436960@attbi _s52>, "McKirahan"
          <News@McKirahan .com> writes:
          [color=blue][color=green]
          >> I have a habit of cleaning up other's code to my conventions...[/color]
          >
          >
          >Oops!
          >
          >Change
          > type="text/lanaguage"
          >to
          > type="text/javascript"[/color]

          Now if we can just get you to snip the ~116 lines that you quoted :)

          --
          Randy

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: onClick onUnClick ???

            McKirahan wrote:
            [color=blue]
            > [monologues][/color]

            How am I supposed to post my replies in a newsgroup?:



            PointedEars

            Comment

            • Dr John Stockton

              #7
              onClick onUnClick ???

              JRS: In article <3FEDBB76.70003 03@PointedEars. de>, seen in
              news:comp.lang. javascript, Thomas 'PointedEars' Lahn
              <PointedEars@we b.de> posted at Sat, 27 Dec 2003 18:03:50 :-
              [color=blue]
              >How am I supposed to post my replies in a newsgroup?:[/color]

              If you do not know, you should read the FAQ of this newsgroup.

              --
              © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
              <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
              <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
              <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

              Comment

              Working...