Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By vishalbiswas

Thread: Can't get this javascript to run...

  1. #1
    Member Stryke_the_Orc's Avatar
    Join Date
    Mar 2014
    Posts
    62
    Member #
    38674
    Liked
    4 times

    [SOLVED]Can't get this javascript to run...

    Hey all,

    Looking for someone to point me to my errors, I'm a total noob to javascript and have followed a few tutorials to come up with what I've got here, but the show/hide functions aren't working.

    Here is my code...

    Code:
    // JavaScript Document
    <script type="text/javascript" language="JavaScript"><!--
    function HideContent(d) {
    document.getElementById(d).style.display = "none";
    }
    function ShowContent(d) {
    document.getElementById(d).style.display = "block";
    }
    function ReverseDisplay(d) {
    if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
    else { document.getElementById(d).style.display = "none"; }
    }
    function HideAllShowOne(d) {
    
    var IDvaluesOfEachDiv = "idone idtwo idthree idfour";
    
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/[,\s"']/g,"version");
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/[,\s"']/g,"general");
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/^\s*/,"appmod");
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/\s*$/,"mw");
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/  +/g,"browser");
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/  +/g,"buddy")
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/  +/g,"camera")
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/  +/g,"ime")
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/  +/g,"email")
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/  +/g,"launcher")
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/  +/g,"settings")
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/  +/g,"mms")
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/  +/g,"contacts")
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/  +/g,"systemui")
    IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/  +/g,"tweaked")
    var IDlist = IDvaluesOfEachDiv.split(" ");
    for(var i=0; i<IDlist.length; i++) { HideContent(IDlist[i]); }
    ShowContent(d);
    }
    
    //--></script>
    I have attached the entire folder/page if the rest is needed.
    I appreciate any help!
    javascript.zip
    Last edited by Stryke_the_Orc; Jul 21st, 2014 at 04:37 PM. Reason: Problem Solved

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    What exactly are you trying to do?
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #3
    Member Stryke_the_Orc's Avatar
    Join Date
    Mar 2014
    Posts
    62
    Member #
    38674
    Liked
    4 times
    I'm trying to create a show/hide setup where the first link shows secondary links, then the content for each secondary link is displayed when clicked.
    As I said, this is entirely new to me, and my faith in the tutorials I used is dwindling lol. I'm hoping I missed something and didn't get bum instructions.

  5. #4
    Junior Member
    Join Date
    Jul 2014
    Posts
    9
    Member #
    39651
    Liked
    1 times
    Many users tend to make this mistake. I reviewed your showhide.js file and found a trivial mistake. When using an external javascript file you must not include the script tag of html. Just remove both the opening javascript comment and html tags viz. opening and closing script tags and the html multiline comment tag.

    Sent from my Nokia_XL
    Stryke_the_Orc likes this.

  6. #5
    Member Stryke_the_Orc's Avatar
    Join Date
    Mar 2014
    Posts
    62
    Member #
    38674
    Liked
    4 times
    Quote Originally Posted by vishalbiswas View Post
    Many users tend to make this mistake. I reviewed your showhide.js file and found a trivial mistake. When using an external javascript file you must not include the script tag of html. Just remove both the opening javascript comment and html tags viz. opening and closing script tags and the html multiline comment tag.

    Sent from my Nokia_XL
    Thank you! This did exactly what I needed it to!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:46 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com