Skip to content

Instantly share code, notes, and snippets.

@Yengas
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save Yengas/9744820 to your computer and use it in GitHub Desktop.

Select an option

Save Yengas/9744820 to your computer and use it in GitHub Desktop.
TeknoBiyotik Pc Sihirbazı, fiyata göre listeleme
function listOptions(id){
var select = document.getElementById(id), options = select.getElementsByTagName("option");
var i, node, objects = {}, keys, match;
for(i = 0; i < options.length; i++){
node = options[i];
if(node == null || node == undefined || (match = node.innerText.match(/([\d]+,[\d]+) TL/)) == null){ continue; }
objects[parseInt(match[1])] = node;
}
keys = Object.keys(objects).sort(function(x, y){ return x - y; });
select.innerHTML = "<option>Seçiniz...</option>";
for(i = 0; i < keys.length; i++){ select.appendChild(objects[keys[i]]); }
}
var selects = document.getElementsByTagName("select"), i;
for(i = 0; i < selects.length; i++){
listOptions(selects[i].id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment