This should be really simple, but I can't get it to work and I'm an absolute beginner with Javascript. I looked at various threads here. I'm working with a django template, on a simple link. I want to add an onclick confirmation message such as 'Trash (14) Projects? Are you sure?' where 14 is the number of checkboxes ready to submit in a form. Right now I have.
<button type="submit" class="actionbutton" name="delete" onclick="return confirm('Add projects to trash - Are you sure?')" >Remove / Add To Trash</button>
Which of course doesn't have the number of projects to be deleted. I could add a script in the head to count the classes of checkboxes, but I want to know how I might execute javascript inside the confirm dialog itself? Such as...
<button type="submit" class="actionbutton" name="delete" onclick="return confirm('Add ($(":checkbox:checked").length) to trash - Are you sure?')" >Remove / Add To Trash</button>
Which doesn't work, probably because the ":checkbox:checked" gets escaped inside the onclick " ".
Anyone point me in the right direction as to what is the 'usual' way to do this kind of thing...
Aucun commentaire:
Enregistrer un commentaire