Getting values of elements passed in data attribute through JQuery
<p>I have some field names populated in the data element.  I'm trying to form a query string with the field names and their corresponding values in the form for using in jquery ajax.  The following code however, does not work for me.</p>

<pre><code>$(".linkedfill").change(function(){
  var params = $(this).data("select-params").split(",");
  $.each(params, function(index,value){
     pname = value.slice(value.IndexOf("["), value.IndexOf("]"));
     pval = $(this).parents().find("[name='"+value+"']").val();
     addparams = addparams + "&amp;" + pname + "=" + pval;
  });
});
</code></pre>

<p>The field name will be like <code>header['fldname']</code> and the field is available somewhere in the same form.  The data-select-params will be like <code>data-select-params="header['fld1'],header['fld2']"</code>.</p>

<p><strong>Update :</strong> My html for fields would look like this:</p>

<pre><code>&lt;input name='header[fld1]' /&gt;
&lt;input name='header[fld2]' /&gt;
&lt;select class='linkedfill' name='pselect' data-select-params="header[fld1],header[fld2]"&gt;
  &lt;option value="opt1"&gt;Option 1&lt;/option&gt;
  &lt;option value="opt2"&gt;Option 2&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>What am trying to do with jquery is get the values of <code>header[fld1]</code> &amp; <code>header[fld2]</code> and form a query string out of the data.</p>

<p>Can anyone help me fix this?  Thanks in advance.</p>
