-1

I am trying to implement a toggle switch in my webpage. I've followed the site below for doing so:

w3schools.com

I currently have my html file set up with a button and this toggle switch. I also configured my webserver in go to be listening on localhost:8080. And I have a websocket handler configured, so that I can easily pass data through to my webpage on the click of the button.

What I want to do create a toggle switch on my webpage that the user can switch on and off, and then have them click a button. After that button is clicked I want to analyse the users selection using an if condition in my golang code based on whether this toggle switch is on/off, but I cannot figure out how to access this value in go. Any suggestions would be helpful. Also, it'd be ideal to have a toggle switch implemented, but if anyone has any simpler ideas for this use case then I'd be open to them.

acer89
  • 45
  • 1
  • 5
  • Asked [here](https://groups.google.com/d/topic/golang-nuts/67FfXqaBdk8/discussion) as well. – kostix Nov 28 '16 at 08:44

1 Answers1

0

Check Below code for On/Off Event :

$('input[name="my-checkbox"]').on('switchChange.bootstrapSwitch', function(event, state) {
  console.log(this); // DOM element
  console.log(event); // jQuery event
  console.log(state); // true | false
});
Laxman Gite
  • 2,248
  • 2
  • 15
  • 23