Widget Javascript codes keep interracting Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
2 posters

    Widget Javascript codes keep interracting

    Ravenstar
    Ravenstar
    Forumember


    Male Posts : 54
    Reputation : 2
    Language : English|Javascript|HTML|Lua|
    Location : :3 somwhere!

    Solved Widget Javascript codes keep interracting

    Post by Ravenstar September 29th 2012, 1:06 am

    Im making Javascript and HTML coding within one widget, however, diffrent parts of coding are interracting with each other, im making buttons that change the words above them, but the buttons are making the wrong words change and into the wrong new statement.....
    then i tried putting them in seperate widgets, but they STILL interracted with each other on the homepage...



    this is the code im using for the first button:
    Code:

    <span style="font-size: 10px; line-height: normal">
    <head>
    <script>
    function myFunction()
    {
    document.getElementById("a").innerHTML="AWCA: Willowstorm,Ravenstar,<br>Oceanstorm,Hazelflower,<br>Spottedleaf,Dovewing,<br>Petalpelt,Eaglestar";
    }
    </script>
    </head>




    <p id="a">The AWCA is an Amazing group of Warrior RP forums, AWCA(awesome warrior cats aliance) is a forum cluster</p>

    <button type="button" onclick="myFunction()">AWCA leaders</button>
    </script>

    here is the code for the second one,
    Code:

    <span style="font-size: 10px; line-height: normal">
    <head>
    <script>
    function myFunction()
    {
    document.getElementById("staff").innerHTML="Willowstorm,Ravenstar,<br>Oceanstorm,Hazelflower,<br>Spottedleaf,Dovewing,<br>Petalpelt,Eaglestar";
    }
    </script>
    </head>



    <p id="staff">Warriorclan staff are<br> Always about, and ready to help!</p>

    <button type="button" onclick="myFunction()">Staff list</button>
    </script>

    but they keep interracting with each other, and also, i want to combine them into one widget, ive tried to do this, but its still the same problem occuring
    please help me


    Last edited by Ravenstar on September 30th 2012, 7:52 am; edited 1 time in total
    Ravenstar
    Ravenstar
    Forumember


    Male Posts : 54
    Reputation : 2
    Language : English|Javascript|HTML|Lua|
    Location : :3 somwhere!

    Solved Re: Widget Javascript codes keep interracting

    Post by Ravenstar September 30th 2012, 7:44 am

    Ok, done, now what?
    Ravenstar
    Ravenstar
    Forumember


    Male Posts : 54
    Reputation : 2
    Language : English|Javascript|HTML|Lua|
    Location : :3 somwhere!

    Solved Re: Widget Javascript codes keep interracting

    Post by Ravenstar September 30th 2012, 8:57 am

    here is the forum link: http://warriorclan.forumotion.com/

    now, go to the widgets on the right, and then look down untill you see the widgets with the buttons "AWCA" and "staff list:"
    and if u click on them, they make the wrong thing happen.


    thats the problem
    nextlevelgaming
    nextlevelgaming
    Forumember


    Male Posts : 989
    Reputation : 38
    Language : English|CSS|HTML5|javascript|
    Location : New York

    Solved Re: Widget Javascript codes keep interracting

    Post by nextlevelgaming September 30th 2012, 9:35 am

    myFunction needs to have two different names. myFunction and myFunction2

    also you did not insert a use strict in your code.

    Code:
    function myFunction() {
    "use strict";
    document.getElementById("staff").innerHTML="Willowstorm,Ravenstar,<br>Oceanstorm,Hazelflower,<br>Spottedleaf,Dovewing,<br>Petalpelt,Eaglestar";
    }
    Code:
    function myFunction2() {
    "use strict";
    document.getElementById...
    Ravenstar
    Ravenstar
    Forumember


    Male Posts : 54
    Reputation : 2
    Language : English|Javascript|HTML|Lua|
    Location : :3 somwhere!

    Solved Re: Widget Javascript codes keep interracting

    Post by Ravenstar September 30th 2012, 9:50 am

    Never mind Everyone!
    my father showed me how, i needed to change
    the "Function myFunction()"
    to "Function (ID word)Function"



    u can toss this into the garbage or something now