dimanche 4 octobre 2015

CGI loop checkbox with javascripts

We have CGI code written in C at here http://ift.tt/1j8Mrww

Basically it generate number of alert from monitoring system and build list of checkbox when you have 100 of alerts then selecting every line individual is painful. I am trying to modify it so i can have select all button which will select everyone in single shot and submit. but i don't know how to do that.

line number 192 where you see following code

if (ackcode) fprintf(output, " <INPUT TYPE=\"CHECKBOX\" NAME=\"CHECKED_%d\" VALUE=\"OFF\">\n", num);

its doing _%d which is number of alerts like

CHECKED_1 CHECKED_2 ...

I am trying to add Javascript so it can select everything in one shot but its not working..like following, but don't know how to look _%d :(

<script language="JavaScript">
function toggle(source) {
  checkboxes = document.getElementsByName('CHECKED');
  for(var i=0, n=checkboxes.length;i<n;i++) {
    checkboxes[i].checked = source.checked;
  }
}

</script>

<center><input type="checkbox" onClick="toggle(this)" /> Toggle All FORM<br/></center>




Aucun commentaire:

Enregistrer un commentaire