Select option value missing in form output

Permalink
Hi guys,

I'm building a website where I need to make a simple function that when you click on a button a option in the form is selected. I do this with jQuery but it needs a value in the from and Concrete5 does not show any value in the html output so I can't get my jQuery to work.

This should be the output, but the value="" is missing in the output HTML at the moment. With other options, like checkbox, it does get the value output.
<select id="question">
  <option value="question1"> question 1</option>
  <option value="question2"> question 1</option>
  <option value="question3"> question 2</option>
  <option value="question4"> question 3</option>
</select>


And this is the jQuery code
$( "h1" ).click(function() {
$("#question").val("question2");
});


I'm using the Tableless form add-on to build the form with div's.

 
mhawke replied on at Permalink Reply
mhawke
Try selecting the appropriate item this way instead...

$('#question>option:eq(1)').attr('selected', true);

http://jsfiddle.net/gaby/CWvwn/...
JaPPa replied on at Permalink Reply
This is a good work-around, thanks! This only works until jQuery version 1.8.2 dough, but that's fine for this project. Do you know a way to add value"" to a option element in the form output aswel, that might be a nice solution for other projects and jQuery upgrades.