具有多个名称的多个复选框

I have multiple check boxes with multiple names defined as(inline HTML):

 echo "<td>"
     echo "<input type = \"checkbox\" name=\"name\" value=\"$name\">";
     echo "<input type = \"hidden\" name=\"user\" value=\"$user\">"; 
 echo "</td>"

When this check box is checked and submitted, it will send the name with the corresponding value to another server. I am using Ruby with Sinatra as the other server to receive the information. For those of you familiar with Sinatra, we use the "params" array method. For example, lets say:

$name = Bob
$user = Bob123

Then when I click submit, I can get the following information by doing this in Sinatra,

puts params[:name] #===>Bob
puts params[:user] #===>Bob123

This is very simple if only one check box is checked and submitted, but things get complicated when multiple check boxes are checked. Using arrays instead of single variables do not work. My goal is to submit to the server once per every checkbox checked. I did some research and it seems I need to use javascript to do this:

print "<script type=\"text/javascript\">
"; 

function submit_data(){
    if (submit) {
        for each checkbox checked {
            Send data to sinatra
        }
    } 
}