Example: http://jsfiddle.net/FyLr9/
I have a search function for a jQueryMobile 1.3 app that has the ability to add or delete filters from it. I need to get and store the select list value (can do) and then apply that to the search input's name attribute.
HTML :
<div class="js-select" data-role="fieldcontain">
<label for="search" class="select">Search By</label>
<select data-role="none" name="select2[]" class="mySelect" data-theme="e">
<option value="1" selected="selected" > Search1</option>
<option value="2" >Search2</option>
<option value="3" >Search3</option>
</select>
<div style="width:100%;height:10px;display:block;"></div>
<label for="search">Search For</label>
<input type="search" name="" id="search" class="inline" value="" placeholder="Search" data-theme="d" data-inline="true">
<a type="button" class="closeselect" id="remove" data-icon="minus" data-iconpos="right" data-inline="true" data-theme="d" data-mini="true">Delete Filter</a>
</div>
JS/jQuery :
$(function(){
$('form').on('change', '.mySelect', function() {
var value = $(this).val();
//alert to show I'm getting the value
alert (value);
$(this).next('input[type="search"]').attr('name') = value;
});
});
[data-type=search]or[type=text]JQM changes input search to data-type=search for markup enhancement.