Here is the next step, keep improving this program
#!/usr/bin/perl -- ## multipeColorSelect.pl ## ## 2014-10-22-02:58:36 ## ## ## ## ## ## ## perltidy -olq -csc -csci=3 -cscl="sub : BEGIN END " -otr -opr -ce +-nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while " -otr + -opr -ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use Carp::Always; Main( @ARGV ); exit( 0 ); sub Main { my %allColors = ( 1 => 'Red', 2 => 'Yellow', 3 => 'Orange', 4 => 'Blue', 5 => 'Black', 6 => 'Brown', 7 => 'Green', 8 => 'White', ); my %mainColors = ( 1 => 'Red', 2 => 'Yellow', 3 => 'Orange', 4 => 'Blue', ); print multipeColorSelect( \%allColors, \%mainColors, 0, 0 ); print multipeColorSelect( \%allColors, \%mainColors, 1, 0 ); #~ print multipeColorSelect( \%allColors, \%mainColors, 1, 1 ); #~ print multipeColorSelect( \%allColors, \%mainColors, 0, 1 ); } ## end sub Main ### FIRST VERSION, THE STUB #~ sub multipeColorSelect { #~ ## my( $all, $main, $checkMain, $checkReset ### RESET?!?!?!? #~ ## my( $all, $main, $selectMain, , $checkRest #~ my( $all, $main, $selectMain, $selectRest ) = @_; #~ return q{ #~ <select id="multipeColorSelect" multiple size="8"> #~ <option value="Red" class="maincolor">Red</option> #~ <option value="Orange" class="maincolor">Orange</option> #~ <option value="Green" class="maincolor">Green</option> #~ <option value="White" class="maincolor">White</option> #~ <option value="Yellow">Yellow</option> #~ <option value="Blue">Blue</option> #~ <option value="Black">Black</option> #~ <option value="Brown">Brown</option> #~ </select> #~ }; #~ } ## end sub multipeColorSelect ### FIRST IMPROVEMENT , FIRST CONDITION, DEFAULT CONDITION, no checkbo +xes selected sub multipeColorSelect { my( $all, $main, $selectMain, $selectRest ) = @_; if( not $selectMain and not $selectRest ) { return q{ <select id="multipeColorSelect" multiple size="8"> <option value="Red" class="maincolor">Red</option> <option value="Orange" class="maincolor">Orange</option> <option value="Green" class="maincolor">Green</option> <option value="White" class="maincolor">White</option> <option value="Yellow">Yellow</option> <option value="Blue">Blue</option> <option value="Black">Black</option> <option value="Brown">Brown</option> </select> }; } else { die "todo"; } } ## end sub multipeColorSelect __END__

This is what happens when I run it (looks good so far)

$ perl multipeColorSelect.pl <select id="multipeColorSelect" multiple size="8"> <option value="Red" class="maincolor">Red</option> <option value="Orange" class="maincolor">Orange</option> <option value="Green" class="maincolor">Green</option> <option value="White" class="maincolor">White</option> <option value="Yellow">Yellow</option> <option value="Blue">Blue</option> <option value="Black">Black</option> <option value="Brown">Brown</option> </select> todo at multipeColorSelect.pl line 82. main::multipeColorSelect('HASH(0x99bbf4)', 'HASH(0xa1019c)', 1 +, 0) called at multipeColorSelect.pl line 41 main::Main() called at multipeColorSelect.pl line 19

Next step, return some different static html for different selecdtMain and selectRest value combinations


In reply to Re^2: Perl and jQuery to select mutiple elements from dropdown by checking checkboxes (multipeColorSelect.pl) by Anonymous Monk
in thread Perl and jQuery to select mutiple elements from dropdown by checking checkboxes by ashraot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.