Just starting to create a javascript function. How do I get the state of a checkbox element in Javascript?
Try to use Toolbox plugin.
Just curious; what are you trying to do?
Want to check the yes/no state in checkbox. Just want to know how to code the line to check the state? Iām currently using Zeroqodeās Javascript plugin. Donāt know if that one or the Toolbox is better for passing individual/list of values back and forth. And if one is easier to work with.
Ok - I switched to using Toolbox. And I tried coding my Action Script to be
setTimeout(function(){bubble_fn_2(document_querySelector(ā#PP CanvasToggle Uppercase Lettersā);},1000);
But that doesnāt work. Anyone know how to get the value from the checkbox (element name is PP Canvas Toggle Uppercase Letters)?
Hi @s.arndt ,
Refer below forum link,
I assume the checkbox is not a bubble element already?
Nearly there, try either of
document.querySelector('#idOfElement').checked // returns true if checked
document.querySelector("input[name='nameOfElement']").checked // returns true if checked
You could also setup an event listener, to send the checked value to bubble when it changes.
no its bubble element. im just trying to understand how to code the javascript to get its value.
Then either of ā¦
or using a parameter
Still not workingā¦Hereās what Iāve tried
var checkedvalue = null;
var cb = document.getElementsByName(āPP Checkbox Uppercase Lettersā).checked;
console.log(cb);
if(cb) {
checkedvalue = cb.value;
}
console.log(checkedvalue);
var aa = document.getElementsByName(āPP Checkbox Uppercase Lettersā).checked;
console.log(aa);
var cc = document.querySelector(āPP Checkbox Uppercase Letters:checkedā).value;
console.log(cc);
And what I get usually is Undefined or Null - even though the checkbox in Bubble is checked.
Please place this text in the element ID attribute like below,
I think, you are using the element name instead of element id attribute.
Okā¦I set the id attribute as shown belowā¦
And I put change the action item to be:
var cc = document.querySelector(ā#PPCHECKBOXUPPERCASELETTERSā).checked;
console.log(cc);
And I still get an Undefined message in the console when I run the workflow - even thought the checkbox is checked. Not sure what Iām doing wrong.
I can review your code if you drop here a link to your editor.
Run in console mode to see the result being sent as a False value (Null) even though the checkbox is checked.
Your app is private. You need to change in settings to make it visible.
Doneā¦
So does mean I need to create my checkboxes in an HTML window instead of using the out-of-the box checkbox element?
Yes. But it wonāt be Bubble.io element
You can check my code that works with Bubble.io. Seem like i made it work. Check it.