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 Coder
    Join Date
    Jul 2005
    Location
    Alabama
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Newbie Problems again

    Yet I am back again I have a simple assignment that I am having problems with. I am really struggling with functions. I will give my assignment description and my actual code. Maybe someone can look at what I am doing wrong and explain it to me and not just give me the answer. Thanks for any that help!
    The Description:
    Code:
    In this project, you will create a script with a function that returns a string value.
     1. Create a new document in your text editor.
     2. Type the <!DOCTYPE> declaration, <html> element, document head, and
        <body> element. Use the Strict DTD and “Company Name” as the content of
        the <title> element.
     3. Create a script section in the document head that contains the following
        getCompanyName() function:
           <script type="text/javascript">
           <!-- HIDE FROM INCOMPATIBLE BROWSERS
           function getCompanyName() {
                var companyName = "Course Technology";
           }
           // STOP HIDING FROM INCOMPATIBLE BROWSERS -->
           </script>
     4. Modify the getCompanyName() function so that it returns the company name
        to another calling function.
    
     5. Add statements after the getCompanyName() function definition that call the
       getCompanyName() function and assign the return value to a variable named
       retValue.
     6. Finally, wr ite code that prints the contents of the retValue var iable.
     7. Save the document as CompanyName.html in the Projects folder for Chapter 3
       and validate it with the W3C MarkUp Validation Service.
     8. Open the CompanyName.html document in your Web browser.
     9. Close your Web browser window.
    My code so far:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <title>Company Name</title>
    <script type="text/javascript">
    <!--Hide from incompatible browsers
    function getCompanyName() 
    {
    	var companyName = "Course Technology";
    	return retValue;
    }
    //Stop hiding from browsers -->
    </script>
    </head>
    <body>
    <script type="text/javascript">
    <!--Hide from incompatible browsers
    var retValue = getCompanyName;
    document.write(retValue);
    </script>
    </body>
    </html>
    Mandriva Club = $12.00/month
    Internet connection = $29.00/month
    A decent laptop = $1200.00
    Switching to Linux = Priceless

    Linux Member # ?????

  • #2
    New Coder
    Join Date
    Jul 2005
    Location
    Alabama
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Found the Problem

    I guess sometimes a make a ant hill into a mountain. Here is a solution:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <title>Company Name</title>
    <script type="text/javascript">
    <!--Hide from incompatible browsers
    function getCompanyName() 
    {
    	var companyName = "Course Technology";
    	return companyName;
    }
    //Stop hiding from browsers -->
    </script>
    </head>
    <body>
    <script type="text/javascript">
    <!--Hide from incompatible browsers
    var retValue = getCompanyName();
    document.write(retValue);
    </script>
    </body>
    </html>
    Mandriva Club = $12.00/month
    Internet connection = $29.00/month
    A decent laptop = $1200.00
    Switching to Linux = Priceless

    Linux Member # ?????


  •  

    Posting Permissions

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