This is my snippet code here.I'm getting some column values from shrepoint list to a dropdpwnlist.But i would like to append the values to a url when an option is selected. So thayt i can use it to filter a list as a parameter. The problem i have is after i select an option and the pages url changes and appends a value to the URL the value i selected isn't set to what i selected but goes back to "select" the default value.
<select id="Phones">
<option value="Select">select</option>
<option value="Alcatel">Alcatel</option>
<option value="BlackBerry">BlackBerry</option>
<option value="HTC">HTC</option>
<option value="Huawei">Huawei</option>
<option value="LG">LG</option>
<option value="Motorola">Motorola</option>
<option value="Nokia">Nokia</option>
<option value="Samsung">Samsung</option>
<option value="Sony">Sony</option>
</select>
// Set the onchange event for the new dropdown
$("#Phones").change(function() { checkSelected(); });
// Run the onchange event to perform any default actions necessary
checkSelected();
function checkSelected() {
// You could use the value of the dropdown in another SPServices request
// here or just perform some other code
var m = $('#Phones').find("option:selected").val();
if (m !== 'Select')
{
var url = "/m.aspx?m=" + m;
window.location = url;
alert(m);
//Tried selecting the selected value here but doesn't work
$('#Phones').children('option:selected').attr("selected","selected");
}
}