Page 1 of 1

Getting if a toggle is checked and set to local variable.

Posted: Wed Apr 17, 2013 7:23 pm
by dale

I have a toggle button, and when the value is changed, I wish to set a local variable.
The toggle is called mobiletoggle1_33.
I'm always get an 'undefined' in the console.log.
I wouldn't usually ask for support as I'm learning, but after a fair few hours it's driving me crazy.

I have set an event for the toggle, onchange, and run javascript.

var meme= Tiggzi('mobiletoggle1_33').attr("checked");
console.log(meme);
localStorage.setItem('dealprom', meme);

var me=localStorage.getItem('dealprom');
console.log(me);

Ta.

Dale.


Getting if a toggle is checked and set to local variable.

Posted: Wed Apr 17, 2013 7:56 pm
by Maryna Brodina

Hello! The toggle button in fact is a Select (see documentation here http://jquerymobile.com/demos/1.2.0/d...). So you would need to get value like from select:
instead of this line codevar meme= Tiggzi('mobiletoggle1_33').attr("checked"); /code use the following codevar meme= Tiggzi('mobiletoggle1_33').val();/code


Getting if a toggle is checked and set to local variable.

Posted: Wed Apr 17, 2013 8:00 pm
by dale

Oh! Haha, silly me ... must admit, wouldn't have thought of that, thought it was like a checkbox.
Thankyou.
Great support as always.
Dale.