Page 1 of 3
Silly checkbox
Posted: Thu Sep 13, 2012 1:27 pm
by Emmz
Pulling my hair out trying to use Custom JS to check a checkbox...
Jquery docs examples dont work...
These also, no go.
$('[dsid="checkbox1"]').prop("checked", true).checkboxradio("refresh");
$('[dsid="checkbox1"]').attr("checked",true);
This works but have many boxes to deal with...
$("input[type='checkbox1']:first").attr("checked",true).checkboxradio("refresh");
How do I select it and check or uncheck it?
And test if checked...
Please help...
Silly checkbox
Posted: Thu Sep 13, 2012 1:45 pm
by Maryna Brodina
Hello Neil! Could you share your App or tell us it's name if App shared already?
Silly checkbox
Posted: Thu Sep 13, 2012 2:06 pm
by Maryna Brodina
Hello! Please try this:
Tiggzi("mobilecheckbox1").find("input[type='checkbox']").attr("checked",true).checkboxradio("refresh");
Tiggzi("mobilecheckbox1").find("input[type='checkbox']").attr("checked",false).checkboxradio("refresh");
I tested this on Button click - it works
Silly checkbox
Posted: Thu Sep 13, 2012 2:36 pm
by Emmz
Freaking awesome Marina !!!
Thank You !
Tiggzi("mycheckbox").find("input[type='checkbox']").attr("checked",true).checkboxradio("refresh");
Works Perfect !
And Use code below to test if checked...
code
var test1 = Tiggzi("checkbox1").find("input[type='checkbox']").attr("checked");
if (test1 == "checked"){
alert ("true");
}else{
alert ("false");
}
/code
I just noticed...
If I use the code u gave to check the box . My code to test box does not work.
If I manualy check the box it does...
Silly checkbox
Posted: Thu Sep 13, 2012 4:14 pm
by Emmz
So how do I test if checked when I us JS to check it. When the the user clicks the check box to uncheck.??
Silly checkbox
Posted: Thu Sep 13, 2012 4:39 pm
by maxkatz
Check what you get in 'test1'.
Silly checkbox
Posted: Thu Sep 13, 2012 5:44 pm
by Emmz
When using the JS function I get "checked" for box checked "undefined" for not checked.
If using JS to check box. Then Manually uncheck box... test1 still shows "checked".
Silly checkbox
Posted: Thu Sep 13, 2012 5:53 pm
by maxkatz
I'd recommend to check jQuery docs, or examples how to do that.
Silly checkbox
Posted: Thu Sep 13, 2012 5:54 pm
by Emmz
For folks later
My work around...
placed Tizzgi Panel.
put in.. code<label><input type="checkbox" name="testbox1" id="testbox1" />test box </label> /code
To check the box using custom JS.
$('input[name=testbox1]').attr('checked', true).checkboxradio("refresh");
Uncheck it..
$('input[name=testbox1]').attr('checked', false).checkboxradio("refresh");
to test if checked...
code
var test1 = $('input[name=testbox1]').is(':checked')
if (test1 == true){
alert ("true" + test1);// returns true
}else{
alert ("false" + test1);//returns false
}
/code
Now even when u use custom JS to make checkbox checked. And the user unchecks the box after. The test if checked returns false like it should.
Silly checkbox
Posted: Tue Feb 17, 2015 7:54 pm
by Mark6921260
I have tried this above and my checkbox doesn't change. Originally the checkbox is set to Selected but if someone wants to opt out they can unclick it. However I need to reset it to Selected for the next person and it is currently not doing that.
Here is what I have:
I am trying to change this checkbox from 'not checked' to 'checked' when I click on the Clear button.
So I've added the following code to the Clear button's Click event. I've three different solutions I have found in the Appery.io forum but none of them work.
Last here is an image showing the name of the check box:
Thank you