norris1023
norris1023

Reputation: 633

Functions with appropriate parameters

Hello everyone I have more of a question. I am working with functions and events now this is what I have so 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 the question I have is I know I am doing something wrong cause it is not showing up on a web page. It is suppose to read my name,age, hobbies, favorite movies. Now do I repeat what I have in the head to the body but instead of the word name I will put my name in there or do I use the if or else(but I am pretty sure that is for the buttons). I also know that I can use an array but I don't know if that would work or not.

Upvotes: 0

Views: 73

Answers (2)

derek
derek

Reputation: 4886

Remove the quotes from around your function parameters:

function printPeronalinfo( name,age,hobbies,favoritemovies)

Then call the function like this:

printPeronalinfo( "name","age","hobbies","favorite movies")

Upvotes: 2

jrn.ak
jrn.ak

Reputation: 36619

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 your 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 also be aware that your function name misspells "Personal" as "Peronal".

Update: In your 2nd <script> block, you have an incorrect comment-block tag: / * should not have a space. This is correct: /*

Upvotes: 2

Related Questions