How to return a matrix of checkbox from client to server side?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Haiyan
    New Member
    • Jul 2010
    • 17

    How to return a matrix of checkbox from client to server side?

    Dear Web application experts:

    I am trying to use Cherrypy to do one web application. I used the cheetah template to generate the HTML file for a matrix of checkbox, and hope to return the checked checkbox information to server side. Because I already used the form for quick selection, and HTML doesn't support nested form. Could you please point me to right way to get the checked checkbox information to server side for handling?
    Following is the HTML code generated by cheetah and you can save as *.html and open with internet browser.

    Code:
    <HTML>
    <HEAD>
    <TITLE>TRY</TITLE>
    
    <STYLE type="text/css">
    body {background-color: "lightyellow";}
    </STYLE>
    
    </HEAD>
    <BODY>
    
    <script language=JavaScript>
    
    function select_all_onclick() {
       document.SelectSlot1.select_slot1.checked = document.SelectAll.select_all.checked
       document.SelectSlot2.select_slot2.checked = document.SelectAll.select_all.checked
       document.SelectSlot3.select_slot3.checked = document.SelectAll.select_all.checked
       document.SelectBoat1.select_boat1.checked = document.SelectAll.select_all.checked
        document.SelectBoat1Slot1.boat1_slot1.checked = document.SelectAll.select_all.checked
        document.SelectBoat1Slot2.boat1_slot2.checked = document.SelectAll.select_all.checked
        document.SelectBoat1Slot3.boat1_slot3.checked = document.SelectAll.select_all.checked
       document.SelectBoat2.select_boat2.checked = document.SelectAll.select_all.checked
        document.SelectBoat2Slot1.boat2_slot1.checked = document.SelectAll.select_all.checked
        document.SelectBoat2Slot2.boat2_slot2.checked = document.SelectAll.select_all.checked
        document.SelectBoat2Slot3.boat2_slot3.checked = document.SelectAll.select_all.checked
       document.SelectBoat3.select_boat3.checked = document.SelectAll.select_all.checked
        document.SelectBoat3Slot1.boat3_slot1.checked = document.SelectAll.select_all.checked
        document.SelectBoat3Slot2.boat3_slot2.checked = document.SelectAll.select_all.checked
        document.SelectBoat3Slot3.boat3_slot3.checked = document.SelectAll.select_all.checked
    }
    
    function select_boat1_onclick(){
        document.SelectBoat1Slot1.boat1_slot1.checked = document.SelectBoat1.select_boat1.checked
        document.SelectBoat1Slot2.boat1_slot2.checked = document.SelectBoat1.select_boat1.checked
        document.SelectBoat1Slot3.boat1_slot3.checked = document.SelectBoat1.select_boat1.checked
    }
    function select_boat2_onclick(){
        document.SelectBoat2Slot1.boat2_slot1.checked = document.SelectBoat2.select_boat2.checked
        document.SelectBoat2Slot2.boat2_slot2.checked = document.SelectBoat2.select_boat2.checked
        document.SelectBoat2Slot3.boat2_slot3.checked = document.SelectBoat2.select_boat2.checked
    }
    function select_boat3_onclick(){
        document.SelectBoat3Slot1.boat3_slot1.checked = document.SelectBoat3.select_boat3.checked
        document.SelectBoat3Slot2.boat3_slot2.checked = document.SelectBoat3.select_boat3.checked
        document.SelectBoat3Slot3.boat3_slot3.checked = document.SelectBoat3.select_boat3.checked
    }
    
    function select_slot1_onclick(){
        document.SelectBoat1Slot1.boat1_slot1.checked = document.SelectSlot1.select_slot1.checked
        document.SelectBoat2Slot1.boat2_slot1.checked = document.SelectSlot1.select_slot1.checked
        document.SelectBoat3Slot1.boat3_slot1.checked = document.SelectSlot1.select_slot1.checked
    }
    function select_slot2_onclick(){
        document.SelectBoat1Slot2.boat1_slot2.checked = document.SelectSlot2.select_slot2.checked
        document.SelectBoat2Slot2.boat2_slot2.checked = document.SelectSlot2.select_slot2.checked
        document.SelectBoat3Slot2.boat3_slot2.checked = document.SelectSlot2.select_slot2.checked
    }
    function select_slot3_onclick(){
        document.SelectBoat1Slot3.boat1_slot3.checked = document.SelectSlot3.select_slot3.checked
        document.SelectBoat2Slot3.boat2_slot3.checked = document.SelectSlot3.select_slot3.checked
        document.SelectBoat3Slot3.boat3_slot3.checked = document.SelectSlot3.select_slot3.checked
    }
    
    
    </script>	  
    
    
    <table border="1" align = "center" bgcolor = "lightblue">
    <thead>
    <TR>
      <TD width=150 align = "center">
      <form name = SelectAll method="POST">
    
      <label>ALL Boats_Slots<input name = "select_all" type = "checkbox" value = "select_all" onclick = "select_all_onclick()"></label>
      </form>
      </TD>
      <TD width=150 align = "center">
      <form name = SelectBoat1 method="POST">
      <label>657762<input name = "select_boat1" type = "checkbox" value = "select_boat1" onclick = "select_boat1_onclick()"></label>
      </form>
      </TD>
    
      <TD width=150 align = "center">
      <form name = SelectBoat2 method="POST">
      <label>657770<input name = "select_boat2" type = "checkbox" value = "select_boat2" onclick = "select_boat2_onclick()"></label>
      </form>
      </TD>
      <TD width=150 align = "center">
      <form name = SelectBoat3 method="POST">
      <label>657775<input name = "select_boat3" type = "checkbox" value = "select_boat3" onclick = "select_boat3_onclick()"></label>
    
      </form>
      </TD>
    </TR>
    </thead>
    <tbody>
    <TR>
     <form name = SelectSlot1 method="POST">
     <TD width=150 align = "center"><label>Slot_1<input name = "select_slot1" type = "checkbox" value = "select_slot1" onclick = "select_slot1_onclick()"></label></TD>
     </form>
     <form name = SelectBoat1Slot1 method="POST">
    
     <TD width=150 align = "center"><label><input name = "boat1_slot1" type = "checkbox" value = boat1_slot1></label></TD>
     </form>
     <form name = SelectBoat2Slot1 method="POST">
     <TD width=150 align = "center"><label><input name = "boat2_slot1" type = "checkbox" value = boat2_slot1></label></TD>
     </form>
     <form name = SelectBoat3Slot1 method="POST">
     <TD width=150 align = "center"><label><input name = "boat3_slot1" type = "checkbox" value = boat3_slot1></label></TD>
     </form>
    </TR>
    
    <TR>
     <form name = SelectSlot2 method="POST">
     <TD width=150 align = "center"><label>Slot_2<input name = "select_slot2" type = "checkbox" value = "select_slot2" onclick = "select_slot2_onclick()"></label></TD>
     </form>
     <form name = SelectBoat1Slot2 method="POST">
     <TD width=150 align = "center"><label><input name = "boat1_slot2" type = "checkbox" value = boat1_slot2></label></TD>
     </form>
     <form name = SelectBoat2Slot2 method="POST">
     <TD width=150 align = "center"><label><input name = "boat2_slot2" type = "checkbox" value = boat2_slot2></label></TD>
    
     </form>
     <form name = SelectBoat3Slot2 method="POST">
     <TD width=150 align = "center"><label><input name = "boat3_slot2" type = "checkbox" value = boat3_slot2></label></TD>
     </form>
    </TR>
    <TR>
     <form name = SelectSlot3 method="POST">
     <TD width=150 align = "center"><label>Slot_3<input name = "select_slot3" type = "checkbox" value = "select_slot3" onclick = "select_slot3_onclick()"></label></TD>
     </form>
    
     <form name = SelectBoat1Slot3 method="POST">
     <TD width=150 align = "center"><label><input name = "boat1_slot3" type = "checkbox" value = boat1_slot3></label></TD>
     </form>
     <form name = SelectBoat2Slot3 method="POST">
     <TD width=150 align = "center"><label><input name = "boat2_slot3" type = "checkbox" value = boat2_slot3></label></TD>
     </form>
     <form name = SelectBoat3Slot3 method="POST">
     <TD width=150 align = "center"><label><input name = "boat3_slot3" type = "checkbox" value = boat3_slot3></label></TD>
     </form>
    
    </TR>
    </tbody>
    </table>
    
    </BODY>
    </HTML>
  • Haiyan
    New Member
    • Jul 2010
    • 17

    #2
    I figured out. I can send the checked checkbox to server side if I only use one form.

    Comment

    Working...