dimanche 25 juillet 2021

How can i process value get from checkbox by JS then do something with it in Java action?

I have a checkbox like this in JSP

<input type="checkbox" id="checkBox" name="checkBox"/>

In JS file I wrote a function to set data for a variable when checkbox be clicked

$("checkBox").change(function(){
var checkBox= 0;
if(this.checked) {
    checkBox= 1;
} else {
    checkBox= 0;
}
})

Then in Java action class I want to do something when checkbox be clicked

if(bean.getCheckBox == 1) {//do something}

But it's not working. Please help me fix this one ! thanks




Aucun commentaire:

Enregistrer un commentaire