473,511 Members | 9,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checkboxes

Hi,

I have a variable number of checkboxes in a form. I have developped a simple
function to calculate a number whith the quantity of checkboxes checked. I
put de JS function in onChange or in onClick whith the same problem:
Function don't execute but after checkbox clicked loses his focus and,
sometimes, if you click in another checkbox inmediatly after a first one,
don't execute the function at all, and I lose information. Any ideas of what
can be the problem?

Thanks for your interest.

Selrak
Jul 23 '05 #1
9 1874
Post ur whole codes out.

ccton

--
www.vicdir.com
"Selrak" <de*************@softhome.net> дÈëÓʼþ
news:6O**********************@telenews.teleline.es ...
Hi,

I have a variable number of checkboxes in a form. I have developped a simple function to calculate a number whith the quantity of checkboxes checked. I
put de JS function in onChange or in onClick whith the same problem:
Function don't execute but after checkbox clicked loses his focus and,
sometimes, if you click in another checkbox inmediatly after a first one,
don't execute the function at all, and I lose information. Any ideas of what can be the problem?

Thanks for your interest.

Selrak

Jul 23 '05 #2
Sorry, I suposed that the code wasn't important for this problem, because,
the code does the expected, but only sometimes the event executes it. Here
goes:

function newImport(document,boolean_canvi,cost)
{
var texteImport = docu.getElementsByName("import_texte");
var cost2;

if(boolean_canvi)
cost2= parseFloat(cost);
else
cost2= parseFloat(cost) * (-1);

texteImport[0].value = (parseFloat(texteImport[0].value) + cost2);
}

I call the function on
<input type="checkbox" onChange="javascript:
newImport(document,this.checked,1.00);" /> //The number 1.00 is an example.
In my code is a PHP variable.

Thanks

Selrak

"CryingClinton" <Cr***********@hotmail.com> escribió en el mensaje
news:cc***********@mail.cn99.com...
Post ur whole codes out.

ccton

--
www.vicdir.com
"Selrak" <de*************@softhome.net> дÈëÓʼþ
news:6O**********************@telenews.teleline.es ...
Hi,

I have a variable number of checkboxes in a form. I have developped a

simple
function to calculate a number whith the quantity of checkboxes checked. I put de JS function in onChange or in onClick whith the same problem:
Function don't execute but after checkbox clicked loses his focus and,
sometimes, if you click in another checkbox inmediatly after a first one, don't execute the function at all, and I lose information. Any ideas of

what
can be the problem?

Thanks for your interest.

Selrak


Jul 23 '05 #3
I guess the following may help a little:

-----------------------------------------------------------
<script>
function show_click(o)
{
document.getElementById('t1').value+="\r\nonclick fires: "+o.checked;
}

function show_change(o)
{
document.getElementById('t1').value+="\r\nonchange fires: "+o.checked;
}
</script>
<input type=checkbox onclick='show_click(this)'
onchange='show_change(this)'>
<textarea id=t1 rows=20 cols=50></textarea>
----------------------------------------------------------

The test code shows the onchange event never fires at the 'input
type=checkbox' object.

ccton

--
www.vicdir.com
"Selrak" <de*************@softhome.net> ????
news:Gh**********************@telenews.teleline.es ...
Sorry, I suposed that the code wasn't important for this problem, because,
the code does the expected, but only sometimes the event executes it. Here
goes:

function newImport(document,boolean_canvi,cost)
{
var texteImport = docu.getElementsByName("import_texte");
var cost2;

if(boolean_canvi)
cost2= parseFloat(cost);
else
cost2= parseFloat(cost) * (-1);

texteImport[0].value = (parseFloat(texteImport[0].value) + cost2);
}

I call the function on
<input type="checkbox" onChange="javascript:
newImport(document,this.checked,1.00);" /> //The number 1.00 is an example. In my code is a PHP variable.

Thanks

Selrak

"CryingClinton" <Cr***********@hotmail.com> escribi?en el mensaje
news:cc***********@mail.cn99.com...
Post ur whole codes out.

ccton

--
www.vicdir.com
"Selrak" <de*************@softhome.net> ????
news:6O**********************@telenews.teleline.es ...
Hi,

I have a variable number of checkboxes in a form. I have developped a simple
function to calculate a number whith the quantity of checkboxes
checked. I put de JS function in onChange or in onClick whith the same problem:
Function don't execute but after checkbox clicked loses his focus and,
sometimes, if you click in another checkbox inmediatly after a first one, don't execute the function at all, and I lose information. Any ideas
of what
can be the problem?

Thanks for your interest.

Selrak



Jul 23 '05 #4
Thanks, I see that onClick is the event I'm looking for, however as you can
note, if you clikc two times too fast, it loses events :(

"CryingClinton" <Cr***********@hotmail.com> escribió en el mensaje
news:cc***********@mail.cn99.com...
I guess the following may help a little:

-----------------------------------------------------------
<script>
function show_click(o)
{
document.getElementById('t1').value+="\r\nonclick fires: "+o.checked;
}

function show_change(o)
{
document.getElementById('t1').value+="\r\nonchange fires: "+o.checked;
}
</script>
<input type=checkbox onclick='show_click(this)'
onchange='show_change(this)'>
<textarea id=t1 rows=20 cols=50></textarea>
----------------------------------------------------------

The test code shows the onchange event never fires at the 'input
type=checkbox' object.

ccton

--
www.vicdir.com
"Selrak" <de*************@softhome.net> ????
news:Gh**********************@telenews.teleline.es ...
Sorry, I suposed that the code wasn't important for this problem, because,
the code does the expected, but only sometimes the event executes it. Here goes:

function newImport(document,boolean_canvi,cost)
{
var texteImport = docu.getElementsByName("import_texte");
var cost2;

if(boolean_canvi)
cost2= parseFloat(cost);
else
cost2= parseFloat(cost) * (-1);

texteImport[0].value = (parseFloat(texteImport[0].value) + cost2);
}

I call the function on
<input type="checkbox" onChange="javascript:
newImport(document,this.checked,1.00);" /> //The number 1.00 is an

example.
In my code is a PHP variable.

Thanks

Selrak

"CryingClinton" <Cr***********@hotmail.com> escribi?en el mensaje
news:cc***********@mail.cn99.com...
Post ur whole codes out.

ccton

--
www.vicdir.com
"Selrak" <de*************@softhome.net> ????
news:6O**********************@telenews.teleline.es ...
> Hi,
>
> I have a variable number of checkboxes in a form. I have developped a simple
> function to calculate a number whith the quantity of checkboxes

checked.
I
> put de JS function in onChange or in onClick whith the same problem:
> Function don't execute but after checkbox clicked loses his focus and, > sometimes, if you click in another checkbox inmediatly after a first

one,
> don't execute the function at all, and I lose information. Any ideas

of what
> can be the problem?
>
> Thanks for your interest.
>
> Selrak
>
>



Jul 23 '05 #5
I dont think so.

Man handing a mouse can not faster than computer, never! :-)

even you focus on the selectbox and press ENTER (this will fire onclick
event as well), the computer still faster than you, nothing will be losed.

ccton
--
www.vicdir.com
"Selrak" <de*************@softhome.net> ????
news:nX**********************@telenews.teleline.es ...
Thanks, I see that onClick is the event I'm looking for, however as you can note, if you clikc two times too fast, it loses events :(

"CryingClinton" <Cr***********@hotmail.com> escribi?en el mensaje
news:cc***********@mail.cn99.com...
I guess the following may help a little:

-----------------------------------------------------------
<script>
function show_click(o)
{
document.getElementById('t1').value+="\r\nonclick fires: "+o.checked;
}

function show_change(o)
{
document.getElementById('t1').value+="\r\nonchange fires: "+o.checked;
}
</script>
<input type=checkbox onclick='show_click(this)'
onchange='show_change(this)'>
<textarea id=t1 rows=20 cols=50></textarea>
----------------------------------------------------------

The test code shows the onchange event never fires at the 'input
type=checkbox' object.

ccton

--
www.vicdir.com
"Selrak" <de*************@softhome.net> ????
news:Gh**********************@telenews.teleline.es ...
Sorry, I suposed that the code wasn't important for this problem, because, the code does the expected, but only sometimes the event executes it. Here goes:

function newImport(document,boolean_canvi,cost)
{
var texteImport = docu.getElementsByName("import_texte");
var cost2;

if(boolean_canvi)
cost2= parseFloat(cost);
else
cost2= parseFloat(cost) * (-1);

texteImport[0].value = (parseFloat(texteImport[0].value) + cost2);
}

I call the function on
<input type="checkbox" onChange="javascript:
newImport(document,this.checked,1.00);" /> //The number 1.00 is an example.
In my code is a PHP variable.

Thanks

Selrak

"CryingClinton" <Cr***********@hotmail.com> escribi?en el mensaje
news:cc***********@mail.cn99.com...
> Post ur whole codes out.
>
> ccton
>
> --
> www.vicdir.com
> "Selrak" <de*************@softhome.net> ????
> news:6O**********************@telenews.teleline.es ...
> > Hi,
> >
> > I have a variable number of checkboxes in a form. I have developped a
> simple
> > function to calculate a number whith the quantity of checkboxes

checked.
I
> > put de JS function in onChange or in onClick whith the same
problem: > > Function don't execute but after checkbox clicked loses his focus and, > > sometimes, if you click in another checkbox inmediatly after a first one,
> > don't execute the function at all, and I lose information. Any

ideas of
> what
> > can be the problem?
> >
> > Thanks for your interest.
> >
> > Selrak
> >
> >
>
>



Jul 23 '05 #6
rf

"CryingClinton" <Cr***********@hotmail.com> wrote in message
news:cc**********@mail.cn99.com...
"Selrak" <de*************@softhome.net> ????
news:nX**********************@telenews.teleline.es ...
Thanks, I see that onClick is the event I'm looking for, however as you can
note, if you clikc two times too fast, it loses events :(

I dont think so.
Man handing a mouse can not faster than computer, never! :-)


I *do* think so, in this instance.

Two very quick mouse clicks are translated into a doubleclick.

The sequence of events is:
onmousedown, onmouseup, onclick, onmouseup, ondblclick

There is only one onclick event. The second "onclick event" is translated
into an ondblclick so the second "onclick event" appears to be lost.

The OP should handle ondblckick events.

--
Cheers
Richard.
Jul 23 '05 #7
I do agree with the ondblclick part.

The page interface should notice the users what's happenning due to their
operation so that they can re-click or something to get the right result. I
mean the page should display the results somewhere, otherwise there always
have troubles.

ccton

--
www.vicdir.com
"rf" <rf@.invalid> news:_O*******************@news-server.bigpond.net.au...

"CryingClinton" <Cr***********@hotmail.com> wrote in message
news:cc**********@mail.cn99.com...
"Selrak" <de*************@softhome.net> ????
news:nX**********************@telenews.teleline.es ...
Thanks, I see that onClick is the event I'm looking for, however as
you can
note, if you clikc two times too fast, it loses events :(

I dont think so.
Man handing a mouse can not faster than computer, never! :-)


I *do* think so, in this instance.

Two very quick mouse clicks are translated into a doubleclick.

The sequence of events is:
onmousedown, onmouseup, onclick, onmouseup, ondblclick

There is only one onclick event. The second "onclick event" is translated
into an ondblclick so the second "onclick event" appears to be lost.

The OP should handle ondblckick events.

--
Cheers
Richard.

Jul 23 '05 #8
Thanks for your answers. I'll try with onDoubleClick event. I'm allways
learning :-)

Selrak

"CryingClinton" <Cr***********@hotmail.com> escribió en el mensaje
news:cc***********@mail.cn99.com...
I do agree with the ondblclick part.

The page interface should notice the users what's happenning due to their
operation so that they can re-click or something to get the right result. I mean the page should display the results somewhere, otherwise there always
have troubles.

ccton

--
www.vicdir.com
"rf" <rf@.invalid>

news:_O*******************@news-server.bigpond.net.au...

"CryingClinton" <Cr***********@hotmail.com> wrote in message
news:cc**********@mail.cn99.com...
"Selrak" <de*************@softhome.net> ????
news:nX**********************@telenews.teleline.es ...
> Thanks, I see that onClick is the event I'm looking for, however as you can
> note, if you clikc two times too fast, it loses events :(
>

I dont think so.
Man handing a mouse can not faster than computer, never! :-)


I *do* think so, in this instance.

Two very quick mouse clicks are translated into a doubleclick.

The sequence of events is:
onmousedown, onmouseup, onclick, onmouseup, ondblclick

There is only one onclick event. The second "onclick event" is translated into an ondblclick so the second "onclick event" appears to be lost.

The OP should handle ondblckick events.

--
Cheers
Richard.


Jul 23 '05 #9
Selrak wrote:
Thanks, I see that onClick is the event I'm looking for, however
as you can note, if you clikc two times too fast, it loses events :(
It is because that double-click is handled by a different event handler,
called "ondblclick". You can probably use event-bubbling in those UAs:

function form_ondblclick(e)
{
var t = (e && e.target || event.srcElement);
(t.click
? t.click(event)
: t.onclick
? t.onclick()
: void 0);
}

<form ... ondblclick="form_ondblclick(event)" ...>

Note: This is partly using proprietary behavior. There is no "dblclick"
event in the W3C DOM Level 2 Events Specification or a [on]click()
method, only an "ondblclick" event handler attribute in the HTML 4.01
Specification.
[...]


Please do not top-post. <http://www.jibbering.com/faq/#FAQ2_3>
PointedEars
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3954
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
2811
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
2812
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
5871
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
2836
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
3178
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
5181
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
11253
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
6018
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
2284
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
7251
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7089
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
451
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.