I am trying to make working model of Stack in which user can select the stack s1 or s2 and can perform operations like push and pop.
I think that you could have more luck with radio buttons. If s1 and s2 were a radio button group, like
<input type="radio" name="stack_select" id="stack1" value="s1">s1
<br>
<input type="radio" name="stack_select" id="stack2" value="s2">s2
Then you can listen to when either changes in one function, and have the other ui components update the proper, selected stack.
The problem with checkboxes for your case is that they aren't mutually exclusive, and it seems like you never want to have both s1 and s2 selected at the same time.