www.webdeveloper.com
Results 1 to 7 of 7

Thread: external JavaScript help

  1. #1
    Join Date
    Dec 2012
    Posts
    6

    external JavaScript help

    Ok I would like to start off by saying that Yes, this is an assignment and YES, I am a moron. I have already determined that I need to change my course of study next semester because all of this is WAY over my head, but i do need to pass so that I still qualify for my grants, I plan on leaving all this web stuff to you professionals (I will stick to accounting thank you! I understand numbers)

    Anyways, I have my .html page and my .js but no matter what I do nothing seems to work.

    HTML Code:
    <!--//Save the HTML file provided in this assignment folder to your computer
    //The contents of this file are irrelevant to the assignment, you just need to manipulate the file
    //Hint: the file will need to be altered, it does not contain "id="
    
    /*Change the href
    Change at least two list items
    Change some verbiage in a paragraph
    Add another href
    Provide a button to toggle between original text and altered text*/ -->
    
    <!DOCTYPE html>
    <html>
    
    <body>
    <script src="A02.js"></script>
    
    <font id= "fontSize" size="2" face="verdana,arial,helvetica,sans-serif">Original Points <br />Due: Friday, April 6th, 2012 at 11:59PM <br />Late: If not turned in by Monday at 11:59PM</font> 
    
    <font size="2" face="verdana,arial,helvetica,sans-serif"><br />Please contact me if you need any help. 
    <b >Put your assignment in a zipped folder and submit it via Blackboard. 
    <br>Zipped folder and assignment naming convention: FirstName_course_Assgn#_StudentId 
    <br /><br /><strong>Include comments and follow the WITC Software Development Standards</strong> 
    
    <div id ="change" ><a href="http://www.nritweb.info/nritweb/booklist/index.htm">Tim the fix-it guy!</a></div>
    <br>
    	<ol >
    	<div id="header"><li>A working machine is a happy machine</div></li>
    		<li>If it&apos;s broke, I can fix-it</li>
    		<li>Fast and effecient</li>
    		<li>Satisfaction guaranteed</li>
    	</ol>
    <!--<button onclick=>
     Change Text</button><br />
     <input type="submit" value="submit" onclick="return foo();" />-->
    
    <input id= "buttonChange" type="button" value="Change Text" name="change" onclick = "getAllFunctions();">
    <input id= "buttonChangeBack" type="button" value="Origianl Text" name="original"> 
    <p>Points breakdown:
    	<ol>
    		<li>As orignially assigned</li> 
    	</ol>
    </p>
    
    </body>
    </html>
    and my js file:
    Code:
    //Save the HTML file provided in this assignment folder to your computer
    //The contents of this file are irrelevant to the assignment, you just need to manipulate the file
    //Hint: the file will need to be altered, it does not contain "id="
    
    /*Change the href
    Change at least two list items
    Change some verbiage in a paragraph
    Add another href
    Provide a button to toggle between original text and altered text*/
    
    function myFunction() 
    {
    
    var textChange = document.getElementById("header");
    var link = document.createElement("div");
    var target = header.createTextMode("This is text I have created");
    textChange.appendChild(target);
    
    function changeText()
    {
    	document.getElementById("change").innerHTML = 'This is the new content';
    	//document.getElementByTag('color').innerHTML = 'This is the new content';
    }
    function getAllFunctions()
    {
    	changeText();
    	myFunction();
    }
    	if(document.getElementById('buttonChange').clicked == true)
    {
    	buttonChange.addEventListener("click", getAllFunctions, false);
    }
        if(document.getElementById('buttonChangeBack').clicked == true)  
    	{
    	window.location.reload();
    	}	  
    
    }

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,255

    Arrow


    if you use the FF or Chrome browsers you can access the error console to see a report of errors that have been found.
    Have you tried that yet?
    What errors did you get?

  3. #3
    Join Date
    Dec 2012
    Posts
    6
    this is the error I get


    NO ELEMENT FOUND
    Last edited by bearsnakes; 03-16-2013 at 04:29 PM.

  4. #4
    Join Date
    Dec 2012
    Location
    NSW Australia
    Posts
    73
    you need to clean up the html to be reasonably valid..

    the JavaScript has more errors than bees in a beehive..

    no matter

    I have taken the core of the html and fixed the JavaScript..

    reluctantly I have added the back to original functionality to the second button...

    this should get you started BUT seeing it is a assignment even that is to much...

    put the script tag at the base as shown in my example...


    HTML Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>xxx</title>
    
    </head>
    <body>
    <div id ="change" >
        <a href="http://www.nritweb.info/nritweb/booklist/index.htm">Tim the fix-it guy!</a>
    </div>
    <ol >
    	<li>A working machine is a happy machine</li>
    	<li>If it&apos;s broke, I can fix-it</li>
    	<li>Fast and effecient</li>
    	<li>Satisfaction guaranteed</li>
    </ol>
    <input id="buttonChange" type="button" value="Change Text" onclick="getAllFunctions();">
    <input id="buttonChangeBack" type="button" value="Origianl Text" onclick="back();"> 
    <script src="AO2.js"></script>
    </body>
    </html>

    Code:
    function changeText() {
        document.getElementById("change").innerHTML = 'This is the new content';
    }
    function getAllFunctions() {
        changeText();
    }
    function back() {
        window.location.reload();
    }
    use the error console every step of the way and only proceed when error free...

    research everything...

  5. #5
    Join Date
    Dec 2012
    Posts
    6
    Thank you to both of you. I had no idea about the error console but am using it now. I am just trying to make it through this semester and then I will bow out gracefully, this is WAY over my head. It was OK last semester when it was just basic HTML but this stuff is beyond crazy. My hats off to you all who can do this.

  6. #6
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,255
    Quote Originally Posted by bearsnakes View Post
    Thank you to both of you. I had no idea about the error console but am using it now. I am just trying to make it through this semester and then I will bow out gracefully, this is WAY over my head. It was OK last semester when it was just basic HTML but this stuff is beyond crazy. My hats off to you all who can do this.
    Soooo, did you solve your problem?

  7. #7
    Join Date
    Dec 2012
    Posts
    6
    it did solve that problem, onward and upward with more problems (different project)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles