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 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    22
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Passing array as argument to function

    Hi everybody. First post. I'm trying to pass an array as an argument for a function on load of an html page, but can't seem to get it to work. Here is my code. Any help would be greatly appreciated.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>List Multiply</title>
    <script type="text/javascript">
    function rotateRight(list){
    	for (var i = 0; i < list.length - 1; i++) {
    		list[i + 1] = list[i];
    		count++;
    	}
    	var swap;
    	var start = 0;
    	list[swap] = list[count];
    	list[count] = list[start];
    	list[start] = list[swap];
    	for (var p = 0; p < list.legth; p++){
    		document.writeln("list[p]'<br />'");
    	}
    }
    	
    		
    
    </script>
    </head>
    
    <body onload="rotateRight(var list[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])">
    </body>

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Code:
    <body onload="rotateRight(var list[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])">
    remove var list, yellow part, from onload.

    best regards

  • Users who have thanked oesxyl for this post:

    amars1983 (03-12-2009)

  • #3
    New Coder
    Join Date
    Mar 2009
    Posts
    22
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oesxyl View Post
    Code:
    <body onload="rotateRight(var list[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])">
    remove var list, yellow part, from onload.

    best regards
    Thank you for the help.


  •  

    Posting Permissions

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