javascript - Functions with appropriate parameters -


hello have more of question. working functions , events have far..

   <!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>    <title>personal information</title>    <meta http-equiv="content-type" content="text/html; charset=utf-8" />    <link rel="stylesheet" href="js_styles.css" type="text/css" />    <script type="text/javascript">    //<![cdata[    function printperonalinfo( "name,age,hobbies,favorite movies") {    document.write("<p>" + name +"</p>");    document.write("<p>" + age +"</p>");    document.write("<p>" + hobbies + "</p>");    document.write("<p>" + favorite video + "</p>");    }    //]]>    </script>    </head>    <body>    <script type="text/javascript">     / * <![cdata[ */    printperonalinfo( "age,age,hobbies,favorite movies")    var return_value = return_message();    document.write(return_value);    /*]]> */     </script>    </body>    </html> 

now question have know doing wrong cause not showing on web page. suppose read name,age, hobbies, favorite movies. repeat have in head body instead of word name put name in there or use if or else(but pretty sure buttons). know can use array don't know if work or not.

you have several mistakes..

function printperonalinfo( "name,age,hobbies,favorite movies") { /*                         ^ no quotes here, ^ invalid variable name */ // should be: function printperonalinfo(name, age, hobbies, favorite_movies) {    document.write("<p>" + name +"</p>");    document.write("<p>" + age +"</p>");    document.write("<p>" + hobbies + "</p>");    document.write("<p>" + favorite video + "</p>");    /*                     ^ undefined variable, isn't defined in function */    // should be: document.write("<p>" + favorite_movies + "</p>"); } 

...

printperonalinfo( "age,age,hobbies,favorite movies"); /*                ^ incorrect passing of data */ // should be: printperonalinfo("name", "age", "hobbies", "favorite movies"); 

you should aware function name misspells "personal" "peronal".

update: in 2nd <script> block, have incorrect comment-block tag: / * should not have space. correct: /*


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -