I have the following problem:
I have a form I need to serialize but I am using javascript to change the look of the select fields. This means, the real select fields
If the issue is caused by hidden elements, temporary show them before serializing:
var $form = $('#myForm');
var hidden = $form.find(':hidden'); // Select all hidden elements
hidden.show(); // Show them
var string = $form.serialize(); // Serialize form
hidden.hide(); // Hide them again
Edit: It seems that you're trying to select an option by setting the selected=selected
attribute. You should use selectedIndex
to change the selected option:
var select = $("#myselect")[0]; //DOM element
select.selectedIndex = 5; //Example, select 6th option