Obtain all input[name='item[]'] in jQuery to pass all selected products via AJAX
<p>I am using the colorbox plugin in jQuery. This allows you to pass data throw a variable 'data' using the same syntax on jQuery.load(), like:</p>

<pre><code>$("#example").colorbox({
    data: { foo: "bar" },
    href: "/example"
});
</code></pre>

<p>My problem is that I need a complex way of passing the data: there is more than one case. The HTML where you will call the colorbox function contains a with:</p>

<ul>
<li>Select between QUANTITY or SERVICES.</li>
<li><ul>
<li>If you select QUANTITY, you have to fill a PRICE.</li>
</ul></li>
<li><ul>
<li>If you fill SERVICES, you have to check (checkboxes) various items in a list (with name="item[]").</li>
</ul></li>
<li>Name destinatary</li>
<li>Name sender</li>
<li>Message</li>
</ul>

<p>My problem is that I don't know how to define this variables dynamically, let me explain. In the href variable case I can do something like:</p>

<pre><code>$("#example").colorbox({
    data: { foo: "bar" },
    href: function() {
         var url = "/example"; // A useless example, but I can do a function here
         return url;
    }
});
</code></pre>

<p>There is anyway I can reproduce this inside the <strong>{ }</strong> of data?</p>

<p>For example:</p>

<pre><code>&lt;input type="radio" name="amount" value="1" /&gt; Quantity
&lt;input type="radio" name="amount" value="0" /&gt; Services

&lt;input type="text" name="quantity" value="" /&gt; Insert a quantity
</code></pre>

<p>Is <code>$("input[name='amount']:checked").val() == 1</code>, I need to pass:</p>

<pre><code>{ amount: 1, quantity: quantity_inserted }
</code></pre>

<p>In the other case, the val() == 0:</p>

<pre><code>&lt;input type="checkbox" name="item[]" value="12_32" /&gt; Item #12
&lt;input type="checkbox" name="item[]" value="13_32" /&gt; Item #13 &lt;- checked
&lt;input type="checkbox" name="item[]" value="14_32" /&gt; Item #14 &lt;- checked
&lt;input type="checkbox" name="item[]" value="15_32" /&gt; Item #15
&lt;input type="checkbox" name="item[]" value="16_32" /&gt; Item #16
&lt;input type="checkbox" name="item[]" value="17_32" /&gt; Item #17 &lt;- checked
&lt;input type="checkbox" name="item[]" value="18_32" /&gt; Item #18 &lt;- ehecked
</code></pre>

<p>I need to pass:</p>

<pre><code>{ amount: 0, items: array_of_values }
</code></pre>

<p>How I can do this?</p>

<p>Thank you in advance!</p>
