Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery slide toggle as a form checkbox

Tags:

jquery

css

forms

How would I go about using something like this Jquery Slide toggle as a checkbox in a form?

JS Fiddle here

Thanks so much in advance. :)

like image 454
banjo Avatar asked Mar 29 '26 17:03

banjo


2 Answers

You could map it to a hidden form element that contains a boolean value, and update that value when the slider is toggled.

Updated fiddle

like image 141
Anthony Grist Avatar answered Mar 31 '26 11:03

Anthony Grist


Here you go, this example show the checkbox: http://jsfiddle.net/skimberk1/TUPG7/

And in this example, it's hidden: http://jsfiddle.net/skimberk1/KNHu7/

The way it works is that it detects if theres a checkbox directly after the toggle, and if there is, it hides it and checks/unchecks it when you slide the toggle.

like image 22
skimberk1 Avatar answered Mar 31 '26 10:03

skimberk1