samedi 16 janvier 2021

How, using a Script, can I make a TagList which interacts with a group of CheckBoxes?

I need a Script for my Asp.Net App which I would like it to do something relatively straightforward and simple. I want a TagList which interacts with a group of CheckBoxes in the View, and just that.

Script

Basically, If I click on a CheckBox below, I want a Tag to appear, in the Tagfield/TagList, with the name that said Checkbox has (which can be the "value=" of the checkbox), and if I click on the X to remove a Tag from the TagList, this unchecks the checkbox associated with that tag. And that's all I need.

Being the code in the View, something as simple as this, which can have a quantity N of Checkboxes.

<div class="wrapper">
 <div><input id=1 type="checkbox" name="group" value="Item 1" class="X"/>Item 1</div>
<div><input id=2 type="checkbox" name="group" value="Item 2" class="X"/>Item 2</div>
<div><input id=3 type="checkbox" name="group" value="Item 3" class="X"/>Item 3</div>
......
<div><input id=N type="checkbox" name="group" value="Item N" class="X"/>Item N</div>
</div>

How can I do it? Thanks in advance if you can help me.




Aucun commentaire:

Enregistrer un commentaire