Skip to content

Instantly share code, notes, and snippets.

@rickslayer
Created July 20, 2020 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickslayer/4f8836c9776e6b77bb1cefc5e1123308 to your computer and use it in GitHub Desktop.
Save rickslayer/4f8836c9776e6b77bb1cefc5e1123308 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script scr="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.js"></script>
</head>
<body>
<select id="teste"></select>
</body>
<script>
$(document).ready(function(){
var oDAdos = dados();
console.log(oDAdos);
var select = $("#teste");
for(var i = 0; i < oDAdos.length; i++)
{
var option = $("<option>");
option.attr("value",oDAdos[i].id);
option.append(oDAdos[i].text);
$(select).append(option);
}
});
function dados()
{
var dados =[
{
id : 1,
text: 'bar'
},
{
id : 2,
text: 'buteco'
},
{
id : 4,
text: 'butecodd'
},
{
id : 5,
text: 'butecofdd'
},
{
id : 6,
text: 'butecofff'
},
{
id : 7,
text: 'buteco66'
}
];
return dados;
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment