http://www.perlmonks.org?node_id=1044518


in reply to Javascript select and unselect all checkboxes not working in Perl CGI code

Your javascript uses a name to access the form (which you provide), but in your call to start_form you don't give it a name.

Replies are listed 'Best First'.
Re^2: Javascript select and unselect all checkboxes not working in Perl CGI code
by begood321 (Novice) on Jul 16, 2013 at 13:59 UTC

    Thanks soonix for your reply. I updated that section of code as follows from examples I've seen:

    start_form(-name=>'forms'),

    However, code still not working. Do you know correct syntax? Searching but haven't found anything PERL CGI related matching exactly call for code below:

    my $JSCRIPT=<<EOF; function selectToggle(toggle, form) { var myForm = document.forms[form]; for( var i=0; i < myForm.length; i++ ) { if(toggle) { myForm.elements[i].checked = "checked"; } else { myForm.elements[i].checked = ""; } } } EOF

    Any other ideas or suggestions?

      The name should be 'theForm' as in the links
      print a( { href => "javascript:selectToggle(true, 'theForm');" }, "All +" ); print " | "; print a( { href => "javascript:selectToggle(false, 'theForm'); +" }, "None" );
      or change the links
      poj

        Thanks Soonix, code to call form below now allows selecting all or none for all checkboxes. I owe you a beer :)

        start_form(-name=>'theForm'),