I am trying the remove the last four characters of each dropdown item in a dynamic file list.
I have tried to use javascript spice syntax after reading this thread, but it seems to remove the full string of the other item in the list rather than just characters. list = list.slice(0, -1);
I'm not sure what is wrong with my approach.
function load_list() {
$("#filename").empty();
$.ajax({
type: 'GET',
dataType: 'json',
url: "/cgi-bin/list_cgi?action=get_list",
success: function(result) {
var list = result.file.sort();
var current = result.current.split("/").pop();
list = list.slice(0, -1);
if (list.length == 0) {
$("#unavailable").html("<h2>File not found, please upload.</h2>");
show_upload();
return;
}
for (var i in list) {
$("filename").append("<option>" + list[i] + "</option>");
}
$("filename").val(current);
}
});
}