lundi 23 octobre 2017

Button instead of checkbox

I use a checkbox to overwrite a database entry, it looks something like this:

[ ] Overwrite 
[Submit]

I want to change the checkbox and submit button to a single button like this:

[Overwrite]

The Checkbox Overwrite function works like this in js:

if(jQuery("#overwrite").prop("checked")){
    data+="&overwrite=on";
}   

And looks like this in html:

<input type="checkbox" id="overwrite" name="overwrite"> Overwrite

I tried doing following in js to use a button instead of a checkbox:

jQuery('#overwrite').click(function(){
    data+="&overwrite=on";
});

And in html the button looks like this:

<button id="overwrite" name="overwrite" type="submit" class="btn btn-primary">Overwrite</button>

The Button won't work, if I click it, nothing happens. what am I doing wrong?




Aucun commentaire:

Enregistrer un commentaire