mercredi 23 septembre 2015

Change checkbox.id by javascript

On my html page I have a checkbox with the ID 100:

<input type=checkbox id=100 onClick="change2(this)" checked>

In the javascript I use the ID within the function for a dygraphs chart:

function change2(el) {
 chart.setVisibility(el.id, el.checked);
}

Problem is that the first dygraphs chart needs to be started by id=0 for visibility of the series. I have two charts on my site so the first chart use the ID's 0-15 and the chekboxes must have unique ID's.

How can I change the function to manipulate the id of the checkbox? Something like chart.setVisibility(el.id - 80, el.checked);

Thanks




Aucun commentaire:

Enregistrer un commentaire