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 14 of 14
  1. #1
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Functions & Arrays Urgent help needed

    I am currently studying JavaScript, and the examples in the textbook is worth SQUAT!! Please help with the following problem.

    A company has a news letter and they want it to be displayed on a web page. They asked you to create a web page that will allow for easy updates each month. The page should be displayed in frames. When the user clicks a news item on the left then the item must open in the right frame.

    1. Create a function to initialise a new array that will store each newsletter news item and its URL.

    2. Create a function that will add a newsletter item to the array. The function should accept a headline and associated URL.

    3. Create the array that will store the news item by calling the function created in steps 1 & 2.
    IMPORTANT TAX LAW CHANGES - tax.htm
    DEDUCTING MEDICAL EXPENSES - medical.htm
    RETIREMENT PLANNING - retire.htm
    UPCOMING SEMINARS - seminars.htm

    4. In the BODY portion of the Web page, enter the code that will display the array items constructed in step 3.


    PLEASE HELP!!

    regards
    cypher

  • #2
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Out of curiousity, do you know what JavaSCript is? Do know what its capable of?
    LovesWar

  • #3
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I only started with JavaScript earlier this year for the first time, but the examples in the textbooks are not very informative. Why do you ask?

  • #4
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I ask because it seems like what you want would entail something other than JavaScript. From what i know, JavaScript can not technically read from files, or write to files, or at least, files that are not HTML. You want for some sort of updater, correct?
    LovesWar

  • #5
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    To tell you the truth I have no idea what to do with this. The problem in the original post is an exact copy of the one I need to complete for an assignment, but the damn thing does not make sense. I think I might be on my way to an answer for the first part. Take a look and tell me what you think.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Parallel Array Test</title>
    <script language="JavaScript">

    function newsArray()
    {
    var Result = "";
    items = ["item1"]
    url = ["http://www.hotmail.com"]
    for (i=0; i<items.length; i++)
    {
    Result += document.write(items[i].link(url[i])) +"\n" ;
    {
    return Result;
    }
    }
    }
    </script>
    </head>

    <body>
    <form name="left">
    <a href="javascript:newsArray()">The first link</a>

    </form>
    </body>
    </html>

  • #6
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    This might help you although i don't see any sense in doing this with a client-side programming language
    Code:
    <html>
    	<head>
    		<script type="text/javascript">
    			function news() {
    				this.content = [[], []];
    				this.add = function(desc, url) {
    					this.content[0].push(desc);
    					this.content[1].push(url);
    				}
    				this.display = function(parent_el) {
    					var div = document.createElement("div");
    					for(var i = 0; i < this.content[0].length; i++) {
    						var anchor = document.createElement("a");
    						anchor.setAttribute("href", this.content[1][i]);
    						var desc = document.createTextNode(this.content[0][i]);
    						anchor.appendChild(desc);
    						div.appendChild(anchor);
    						div.appendChild(document.createElement("br"));
    					}
    					parent_el.appendChild(div);
    				}
    			}
    			function init() {
    				news = new news();
    				news.add("IMPORTANT TAX LAW CHANGES", "tax.htm");
    				news.add("DEDUCTING MEDICAL EXPENSES", "medical.htm");
    				news.add("RETIREMENT PLANNING", "retire.htm");
    				news.add("UPCOMING SEMINARS", "seminars.htm");
    				news.display(document.getElementsByTagName("body")[0]);
    			}
    			window.onload = init;
    		</script>
    	</head>
    	<body>
    	</body>
    </html>
    dumpfi

  • #7
    Regular Coder
    Join Date
    Jul 2004
    Location
    engoku no anime
    Posts
    354
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Think of it this way: It's a textbook! It is useless to consult it! The Internet has better, clearer information!

  • #8
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    You could think of it that way. But a text book will go into far more depth of a programming language and they are nice to have around. For one the information therein has gone through an editor and and been published as fact. There is no such process with a webpage. The internet is good for the basics and in a case where you may need a different explanation giving this forum a nice little place in the world.

    Basscyst
    Helping to build a bigger box. - Adam Matthews

  • #9
    Regular Coder
    Join Date
    Jul 2004
    Location
    engoku no anime
    Posts
    354
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I reckon your right Mr. Bass.

  • #10
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    THANX!! Just one more thing. How can I display the contents of the selected URL in another frame instead of a new window?

  • #11
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nevermind I just made a little spelling mistake when I set the attributes, everything is working fine now.

  • #12
    New Coder
    Join Date
    Jul 2004
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Question on frames

    GoodDay

    I am doing the exact same assignment as Mr Cypher083

    Thanx to Mr Dumpfi everthing is working except,

    Can anybody help me to display the contents of the selected URL in the body frame instead of a new window? I have 2 frames: A Left Frame and a right (body) frame.

    The link to the url is in the left frame and when clicked it must open in the right frame.

    Please Help???

  • #13
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hint: Change this line to target your iframe....

    window.onload = init;

  • #14
    New Coder
    Join Date
    Jul 2004
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank You Mr Willy Duitt. I appreciate your help and I see you gave a comment on my other question for the calculation.

    I am going to look at it now

    Thanx


  •  

    Posting Permissions

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