HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
A controller is a function you write to control your data
A controller is a function you write to control your data.
With a self-written controller, you can modify data anyway you want:
You want to convert your data to upper case before display.
<script>
w3.getHttpObject("customers.js", myFunction);
function myFunction(myObject) {
var i;
var myArray = myObject.customers;
for (i = 0; i <
myArray.length; i++) {
myArray[i]["CustomerName"]
=
myArray[i]["CustomerName"].toUpperCase();
}
w3.displayObject("id01", myObject);
}
</script>
<script>
w3.getHttpObject("cd_catalog.js", myFunction);
function
myFunction(myObject) {
var i, total = 0;
var myArray = myObject.cd;
for (i = 0; i <
myArray.length; i++) {
total +=
Number(myArray[i].price);
}
myObject.total = total.toFixed(2);
w3.displayObject("id01", myObject);
}
</script>