顯示對象
W3Data的目的是為了顯示在HTML頁面中的數據。
為了證明W3Data的力量,我們將顯示一個JavaScript對象(myObject的)。
目的是與客戶名稱,客戶市對象和國家性質的數組:
myObject的
var myObject = {"customers":[
{"CustomerName":"Alfreds Futterkiste","City":"Berlin","Country":"Germany"},
{"CustomerName":"Around the Horn","City":"London","Country":"UK"},
{"CustomerName":"B's
Beverages","City":"London","Country":"UK"},
{"CustomerName":"Blauer See
Delikatessen","City":"Mannheim","Country":"Germany"},
{"CustomerName":"Bon
app'","City":"Marseille","Country":"France"},
{"CustomerName":"Bottom-Dollar
Marketse","City":"Tsawassen","Country":"Canada"},
{"CustomerName":"Chop-suey
Chinese","City":"Bern","Country":"Switzerland"}
]};
灌裝下拉
例
<select id="id01">
<option w3-repeat="customers">{{CustomerName}}</option>
</select>
<script>
w3DisplayData("id01", myObject);
</script>
試一試» 填充列表
例
<ul id="id01">
<li w3-repeat="customers">{{CustomerName}}</li>
</ul>
<script>
w3DisplayData("id01", myObject);
</script>
試一試» 灌裝檢查盒
例
<table id="id01">
<tr w3-repeat="customers" class="{{Color}}">
<td>{{CustomerName}}</td>
<td><input
type="checkbox" {{checked}}"></td>
</tr>
</table>
<script>
w3DisplayData("id01", myObject);
</script>
試一試» 灌裝類
例
<table id="id01">
<tr w3-repeat="customers" class="{{Color}}">
<td>{{CustomerName}}</td>
</tr>
</table>
<script>
w3DisplayData("id01", myObject);
</script>
試一試» 例
<table id="id01">
<tr w3-repeat="customers" class="{{Size}}">
<td>{{CustomerName}}</td>
</tr>
</table>
<script>
w3DisplayData("id01", myObject);
</script>
試一試» 填寫表
例
<table id="id01">
<tr>
<th>Customer</th>
<th>City</th>
<th>Country</th>
</tr>
<tr w3-repeat="customers">
<td>{{CustomerName}}</td>
<td>{{City}}</td>
<td>{{Country}}</td>
</tr>
</table>
<script>
w3DisplayData("id01", myObject);
</script>
試一試»