473,382 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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.<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
4 2875
"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
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Pete | last post by:
There is a Summary/Example further down... On page one of my site I have a form with some checkboxes and detailed descriptions. When the form is submitted (to page two), the values of the...
8
by: DylanM | last post by:
I have some checkboxes that are generated from the results of a database search. At the moment, the checkboxes are part of a table making up a form. Users are going through the form, clicking the...
8
by: Ralph Freshour | last post by:
I have multiple checkbox's created with an array name because I have many on the same web page - their names are like: frm_chk_delete frm_chk_delete frm_chk_delete frm_chk_delete etc. Here...
5
by: @(none) | last post by:
I have a page which is a set of CheckBoxes generated daily and thus the number of Checkboxes changes each day. What I want to do is allow the user to select one or more checkboxes and the push a...
6
by: terence.parker | last post by:
I currently have the following JS in my header: function checkall(thestate) { var checkboxes=eval("document.forms.EssayList.file_id") for (i=0;i<checkboxes.length;i++)...
2
by: john | last post by:
I posted this question to comp.lang.javascript but didn't get a response, so I'll try here. I am using ASP.NET and I have a datagrid. One of the columns in my grid is all checkboxes. When the...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
5
by: masterej | last post by:
Developers, Is there any way to disable all checkboxes on a form? I have a form with 160 checkboxes and I want to be able to disable all of them. Is there a way I can do something like this: ...
8
by: PeteOlcott | last post by:
http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/grid/tests/test_change_structure.html I would like to completely understand how GUI controls such as this one are constructed. In the...
7
by: viki1967 | last post by:
I need one function javascript that: 1) when I enter in this htm page I see enabled only checkbox of categories A, M and T; checkboxes of microcategories all disabled; 2-a) If I select the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.