113
rated 0 times
[
117]
[
4]
/ answers: 1 / hits: 35175
/ 11 Years ago, tue, october 29, 2013, 12:00:00
I know that several questions about this topic have been asked, but I was unable to find an answer for my case.
I have a checked checkbox
as
<input type=checkbox name=text checked=checked />
I need to send ajax request by checking/unchecking, but I do not know what can be the reliable (with browser compatibility) for an if statement
such as
if (this.value == 'on')
{
this.value = 'off';
ajax call;
}
else
{
this.value ='on';
ajax call;
}
Note that the value is not important here, and we need to catch checked/unchecked
, but how control the checked element by JavaScript
when the html original element has checked=checked
?
If using checked
instead of value
as
if (this.checked == true)
{
this.checked = false;
ajax call;
}
else
{
this.checked =true;
ajax call;
}
The tick of checkbox
will not be changed in the browser (always ticked).
More From » checkbox