By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,568 Members | 1,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,568 IT Pros & Developers. It's quick & easy.

checkboxes

P: n/a
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.<script

<!--
function pruefen(){return true}
-->
</script>
<script language="JAvaScript1.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="return pruefen(this)"></form>

Thank you
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"BjoernJackschina" <ja*******@hotmail.com> wrote in message
news:a2**************************@posting.google.c om...
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.<script

<!--
function pruefen(){return true}
-->
</script>
<script language="JAvaScript1.1"><!--
language attribute is deprecated, type attribute is required
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 */
f is object allready since you have "onSubmit="return pruefen(this)". And
"this" means this form. Use:

f.elements
<form onSubmit="return pruefen(this)"></form>

Jul 20 '05 #2

P: n/a
BjoernJackschina wrote on 02 Dec 2003:
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.<script
My reply to your original contains more elaborate response. Please
read that after this.
<!--
function pruefen(){return true}
-->
</script>
<script language="JAvaScript1.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 */
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="someFunction(this)">

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

<FORM id="eg2" ... onsubmit="someFunction(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="someFunction(this)">

....and this function:

function someFunction( obj ) {
// Here, obj would be the same as using document.forms['myForm']
}
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 ? */
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?
<form onSubmit="return pruefen(this)"></form>


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

Mike

--
Michael Winter
M.******@blueyonder.co.uk.invalid (remove ".invalid" to reply)
Jul 20 '05 #3

P: n/a
"Vjekoslav Begovic" <vj*******@inet.hr> wrote in message news:<bq**********@ls219.htnet.hr>...
"BjoernJackschina" <ja*******@hotmail.com> wrote in message
news:a2**************************@posting.google.c om...
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.<script

<!--
function pruefen(){return true}
-->
</script>
<script language="JAvaScript1.1"><!--


language attribute is deprecated, type attribute is required
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 */


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

f.elements
<form onSubmit="return pruefen(this)"></form>


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.length;i++).
What could be the problem. I couldn't find it.

Many thanks
Jul 20 '05 #4

P: n/a
Michael Winter <M.******@blueyonder.co.uk.invalid> wrote in message news:<Xn*******************************@193.38.113 .46>...
BjoernJackschina wrote on 02 Dec 2003:
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.<script


My reply to your original contains more elaborate response. Please
read that after this.
<!--
function pruefen(){return true}
-->
</script>
<script language="JAvaScript1.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 */


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="someFunction(this)">

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

<FORM id="eg2" ... onsubmit="someFunction(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="someFunction(this)">

...and this function:

function someFunction( obj ) {
// Here, obj would be the same as using document.forms['myForm']
}
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 ? */


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?
<form onSubmit="return pruefen(this)"></form>


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

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.