I'm trying to use jQuery to combine the user's select field choices (category + contributors) and insert this into a hidden field with an id of as_q, but when I run the script the value of as_q is always empty.
At the moment, I call the function when the user clicks submit - it gets the value of the two select fields and combines them, before assigning them to the as_q field - at least that's my logic.
Perhaps I've got the in the wrong place? My current code is below. Any help greatly appreciated, thanks
<form action="<? echo $PHP_SELF;?>" method="get" id="cse-search-box">
<input type="text" name="q" size="31"/>
<select name="category">
<option>Movies</option>
<option>Film</option>
<option>Fashion</option>
</select>
<select name="contributors">
<option>One</option>
<option>Two</option>
<option>Three</option>
</select>
<input type="hidden" name="as_q" id="as_q" value="" />
<input type="submit" name="sa" value="Search" id="submit_query" />
</form>
<script>
$('#submit_query').click(function (){
var category = $('[name=category]').val();
var contributors = $('[name=contributors]').val();
$('[#as_q]').val(category+' '+contributors);
});
</script>