Here's an alternative solution assuming jQuery is available. If you use a js utility library other than jQuery, or no library at all, this is still possible. Its just binding a function to the select's onchange event and parsing the json from a custom data-attribute.
<form>
<select name="AnySelect">
<option value="primary-value0" data-support='["test",128,2014,"blackberry"]' />
<option value="primary-value1" data-support='["test1",39,2013,"apricot"]' />
<option value="primary-value2" data-support='["test2",42,2012,"peach"]' />
<option value="primary-value3" data-support='[null,null]' />
<option value="primary-value4" data-support='[30,28,null]' />
</select>
.
.
.
<span style="visibility: hidden" id="Support_AnySelect-container"><span>
</form>
^ Markup ------- JavaScript v
//bind onchange once document is loaded and ready
$.ready(function(){ $('#TheSelector').on('change',UpdateHidden); });
function UpdateHidden(event)
{
//Create a base name for grouping dynamic values; ex: Support_AnySelect
Name='Support_'+SelectField.attr('name');
//Check if container was made for us already
Contain=$(this.parent).find('#'+Name+'-container');
if(Container.length===0) //make the container if missing
{
$(this).after('<span id="'+Name+'-container" style="visibility: none;"></span>');
Contain=$(this.parent).children('#'+Name+'-container');
}
//get our special multi-values, jQuery will auto decode the JSON
SupportValues = this.data('support');
Contain.empty(); //get rid of last select options
$.each(SupportValues,function(i,val)
{
Contain.append('<input type="hidden" name="'+Name+'['+i+'] value="'+val+'"/>');
});
}
Main benefit of this is that it should, in theory, let you post a 'variable amount of variables' from the form. You could also adjust the script to account for certain nested objects. As long as you pass in valid JSON to the data-attribute of your choice.
If anyone tries this out before I do, please let me know. I will test this later on but may have some minor errors.You should be able to use this on any select element and have hidden inputs automatically populate inside another element; script should also guarantee these to be in the same form tag for you and having unique but grouped names via HTTP array.