checkboxes

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

    checkboxes

    HEllo,
    I still have always the same problem with a no object form in my
    source code.
    It is for checking out used radiobuttons or checkboxes.<scr ipt

    <!--
    function pruefen(){retur n true}
    -->
    </script>
    <script language="JAvaS cript1.1"><!--
    function pruefen(f){
    var i;
    var k=0;
    document.forms[f].elements; /* this sould be an object form but I
    can't find the syntax-mistake */

    for(i=0; i < f.elem.length; i++){

    if ('checkbox' == elem[i].type)
    {
    if(elem[i].checked)
    k++;
    }
    }return true;
    }
    /* So actually I need k for continue. Maybe it has to give back k ? */

    <form onSubmit="retur n pruefen(this)"> </form>

    Thank you
  • Vjekoslav Begovic

    #2
    Re: checkboxes

    "BjoernJackschi na" <jacksch_1@hotm ail.com> wrote in message
    news:a24000a2.0 312020643.7ef4c cfe@posting.goo gle.com...[color=blue]
    > HEllo,
    > I still have always the same problem with a no object form in my
    > source code.
    > It is for checking out used radiobuttons or checkboxes.<scr ipt
    >
    > <!--
    > function pruefen(){retur n true}
    > -->
    > </script>
    > <script language="JAvaS cript1.1"><!--[/color]

    language attribute is deprecated, type attribute is required
    [color=blue]
    > function pruefen(f){
    > var i;
    > var k=0;
    > document.forms[f].elements; /* this sould be an object form but I
    > can't find the syntax-mistake */[/color]

    f is object allready since you have "onSubmit="retu rn pruefen(this)". And
    "this" means this form. Use:

    f.elements
    [color=blue]
    > <form onSubmit="retur n pruefen(this)"> </form>[/color]


    Comment

    • Michael Winter

      #3
      Re: checkboxes

      BjoernJackschin a wrote on 02 Dec 2003:
      [color=blue]
      > HEllo,
      > I still have always the same problem with a no object form in my
      > source code.
      > It is for checking out used radiobuttons or checkboxes.<scr ipt[/color]

      My reply to your original contains more elaborate response. Please
      read that after this.
      [color=blue]
      > <!--
      > function pruefen(){retur n true}
      > -->
      > </script>
      > <script language="JAvaS cript1.1"><!--
      > function pruefen(f){
      > var i;
      > var k=0;
      > document.forms[f].elements; /* this sould be an object form but
      > I can't find the syntax-mistake */[/color]

      No, it should *not*!! When you use the this operator in an event
      handler, it evaluates to an object reference of the element it is in.
      For example:

      <INPUT id="eg1" type="checkbox" onclick="someFu nction(this)">

      someFunction() is passed a reference to an Input (in JS) or
      HTMLInputElemen t (in DOM) object with the id, eg1.

      <FORM id="eg2" ... onsubmit="someF unction(this)">

      someFunction() is passed a reference to a Form (in JS) or
      HTMLFormElement (in DOM) object with the id, eg2.

      If you had a form, such as this one:

      <FORM name="myForm" onsubmit="someF unction(this)">

      ....and this function:

      function someFunction( obj ) {
      // Here, obj would be the same as using document.forms['myForm']
      }
      [color=blue]
      > for(i=0; i < f.elem.length; i++){
      >
      > if ('checkbox' == elem[i].type)
      > {
      > if(elem[i].checked)
      > k++;
      > }
      > }return true;
      > }
      > /* So actually I need k for continue. Maybe it has to give back
      > k ? */[/color]

      To answer that, you need to tell us (and I said this in my other
      reply) what the validator is checking, what is a success condition,
      and what is a failure condition. You said that you checked k - for
      what? Where will you check it?
      [color=blue]
      > <form onSubmit="retur n pruefen(this)"> </form>[/color]

      Don't forget to read my reply to your original post.

      Mike

      --
      Michael Winter
      M.Winter@blueyo nder.co.uk.invalid (remove ".invalid" to reply)

      Comment

      • BjoernJackschina

        #4
        Re: checkboxes

        "Vjekoslav Begovic" <vjbegovic@inet .hr> wrote in message news:<bqiaao$l8 e$1@ls219.htnet .hr>...[color=blue]
        > "BjoernJackschi na" <jacksch_1@hotm ail.com> wrote in message
        > news:a24000a2.0 312020643.7ef4c cfe@posting.goo gle.com...[color=green]
        > > HEllo,
        > > I still have always the same problem with a no object form in my
        > > source code.
        > > It is for checking out used radiobuttons or checkboxes.<scr ipt
        > >
        > > <!--
        > > function pruefen(){retur n true}
        > > -->
        > > </script>
        > > <script language="JAvaS cript1.1"><!--[/color]
        >
        > language attribute is deprecated, type attribute is required
        >[color=green]
        > > function pruefen(f){
        > > var i;
        > > var k=0;
        > > document.forms[f].elements; /* this sould be an object form but I
        > > can't find the syntax-mistake */[/color]
        >
        > f is object allready since you have "onSubmit="retu rn pruefen(this)". And
        > "this" means this form. Use:
        >
        > f.elements
        >[color=green]
        > > <form onSubmit="retur n pruefen(this)"> </form>[/color][/color]

        Hello,
        if I use f.elements I have the problem with a part of the for-loop. So
        it is to object to ( i=0;i < f.elements.leng th;i++).
        What could be the problem. I couldn't find it.

        Many thanks

        Comment

        • BjoernJackschina

          #5
          Re: checkboxes

          Michael Winter <M.Winter@bluey onder.co.uk.inv alid> wrote in message news:<Xns9445A3 9861AA3MWinterB lueyonder@193.3 8.113.46>...[color=blue]
          > BjoernJackschin a wrote on 02 Dec 2003:
          >[color=green]
          > > HEllo,
          > > I still have always the same problem with a no object form in my
          > > source code.
          > > It is for checking out used radiobuttons or checkboxes.<scr ipt[/color]
          >
          > My reply to your original contains more elaborate response. Please
          > read that after this.
          >[color=green]
          > > <!--
          > > function pruefen(){retur n true}
          > > -->
          > > </script>
          > > <script language="JAvaS cript1.1"><!--
          > > function pruefen(f){
          > > var i;
          > > var k=0;
          > > document.forms[f].elements; /* this sould be an object form but
          > > I can't find the syntax-mistake */[/color]
          >
          > No, it should *not*!! When you use the this operator in an event
          > handler, it evaluates to an object reference of the element it is in.
          > For example:
          >
          > <INPUT id="eg1" type="checkbox" onclick="someFu nction(this)">
          >
          > someFunction() is passed a reference to an Input (in JS) or
          > HTMLInputElemen t (in DOM) object with the id, eg1.
          >
          > <FORM id="eg2" ... onsubmit="someF unction(this)">
          >
          > someFunction() is passed a reference to a Form (in JS) or
          > HTMLFormElement (in DOM) object with the id, eg2.
          >
          > If you had a form, such as this one:
          >
          > <FORM name="myForm" onsubmit="someF unction(this)">
          >
          > ...and this function:
          >
          > function someFunction( obj ) {
          > // Here, obj would be the same as using document.forms['myForm']
          > }
          >[color=green]
          > > for(i=0; i < f.elem.length; i++){
          > >
          > > if ('checkbox' == elem[i].type)
          > > {
          > > if(elem[i].checked)
          > > k++;
          > > }
          > > }return true;
          > > }
          > > /* So actually I need k for continue. Maybe it has to give back
          > > k ? */[/color]
          >
          > To answer that, you need to tell us (and I said this in my other
          > reply) what the validator is checking, what is a success condition,
          > and what is a failure condition. You said that you checked k - for
          > what? Where will you check it?
          >[color=green]
          > > <form onSubmit="retur n pruefen(this)"> </form>[/color]
          >
          > Don't forget to read my reply to your original post.
          >
          > Mike
          >
          >Hello Mike,
          > I will test your tipps but I can give you an answer only tomorrow.
          >Many thanks[/color]

          Comment

          Working...