<!DOCTYPE html>
<html>
<body>
<style>
.objeTablo th, .objeTablo tr, .objeTablo td
{
padding: 5px;
border: solid 1px #f00;
color: #717171;
text-align: center;
}
</style>
<label>Listelenecek Objeyi Gir</label><br/> <input type="text" name="obje" /><br/><input type="button" value="Obje Göster" onclick="objGoster()" /><br/>
<textarea col="50" rows="20" name="jsonGir"></textarea>
<table id="tabloIcerik" class="objeTablo" style="max-width: 800px; height: auto;
border: solid 1px #f00;" cellspacing="0" cellpadding="0">
<tr>
<th>
Nesne
</th>
<th>
Nesne Değeri
</th>
</tr>
</table>
<script>
function objGoster(){
var jsonVeri = document.getElementsByName("jsonGir")[0].value;
var jsonAra = document.getElementsByName("obje")[0].value;
var obj = JSON.parse(jsonVeri);
var icerik = "";
for (i = 0; i < obj.length; i++) {
icerik += "<tr><td> " +jsonAra + " </td><td> " + obj[i][jsonAra] + " </td></tr>";
}
document.getElementById("tabloIcerik").innerHTML = icerik;
}
</script>
</body>
</html>
Nesne | Nesne Değeri |
---|
Hiç yorum yok:
Yorum Gönder