0

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

Kᴀτᴢ
  • 2,146
  • 6
  • 29
  • 57
  • 1
    might help you http://stackoverflow.com/questions/1650299/how-do-i-change-the-id-of-a-html-element-with-javascript – shreesha Sep 23 '15 at 11:50

1 Answers1

1

Since el is a reference of the DOM element, to change its id you can use:

el.id = el.id-80;

and then pass el to your function.

Irvin Dominin
  • 30,819
  • 9
  • 77
  • 111