...

View Full Version : Display in Array



ch1326
06-22-2009, 02:03 PM
Hello every, I have tried to use array object to display a result on my browser but nothing show up. Please help




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Learn JS</title>
<script type = 'text/javaScript' language = 'javascript'>

function automobile (manuf, model, series){
this.manuf = manuf;
this.model = model;
this.series = series;
}

myAutomobile = new array(5);
myAutomobile[0] = new automobile ('Aston Martin', 'DB', 'DB9 Sports Pack');
myAutomobile[1] = new automobile ('Aston Martin', 'DB', 'DB9 Sports Pack');
myAutomobile[2] = new automobile ('Aston Martin', 'DB', 'DB9 Sports Pack');
myAutomobile[3] = new automobile ('Aston Martin', 'DB', 'DB9 Sports Pack');
myAutomobile[4] = new automobile ('Aston Martin', 'DB', 'DB9 Sports Pack');



function get_automobile () {
for (i=0; i < myAutomobile.length; i++) {
obj = myAutomobile[i];

document.write(
'Manufacture: ' + obj.manuf + '<br>' +
'Model: ' + obj.model + '<br>' +
'Series: ' + obj.series + '<br><br>'
);
}
}

</script>

</head>

<body>

<script type = 'text/javaScript' language = 'javascript'>
get_automobile () ;
</script>

</body>
</html>

vwphillips
06-22-2009, 03:45 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Learn JS</title>
<script type = 'text/javaScript' language = 'javascript'>

function automobile (manuf, model, series){
this.manuf = manuf;
this.model = model;
this.series = series;
}

myAutomobile = [];
myAutomobile[0] = new automobile ('Aston Martin', 'DB', 'DB9 Sports Pack');
myAutomobile[1] = new automobile ('Aston Martin', 'DB', 'DB9 Sports Pack');
myAutomobile[2] = new automobile ('Aston Martin', 'DB', 'DB9 Sports Pack');
myAutomobile[3] = new automobile ('Aston Martin', 'DB', 'DB9 Sports Pack');
myAutomobile[4] = new automobile ('Aston Martin', 'DB', 'DB9 Sports Pack');



function get_automobile () {
for (i=0; i < myAutomobile.length; i++) {
obj = myAutomobile[i];

document.write(
'Manufacture: ' + obj.manuf + '<br>' +
'Model: ' + obj.model + '<br>' +
'Series: ' + obj.series + '<br><br>'
);
}
}

</script>

</head>

<body>

<script type = 'text/javaScript' language = 'javascript'>
get_automobile () ;
</script>

</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum