Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Display in Array

    Hello every, I have tried to use array object to display a result on my browser but nothing show up. Please help

    Code:
    <!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>

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,511
    Thanks
    3
    Thanked 504 Times in 491 Posts
    Code:
    <!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>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •