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.

Widget Javascript codes keep interracting

2 posters

Go down

Solved Widget Javascript codes keep interracting

Post by Ravenstar Sat 29 Sep 2012 - 1:06

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 Sun 30 Sep 2012 - 7:52; edited 1 time in total
Ravenstar
Ravenstar
Forumember

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

http://warriorclan.forumotion.com/

Back to top Go down

Solved Re: Widget Javascript codes keep interracting

Post by Ravenstar Sun 30 Sep 2012 - 7:44

Ok, done, now what?
Ravenstar
Ravenstar
Forumember

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

http://warriorclan.forumotion.com/

Back to top Go down

Solved Re: Widget Javascript codes keep interracting

Post by Ravenstar Sun 30 Sep 2012 - 8:57

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
Ravenstar
Ravenstar
Forumember

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

http://warriorclan.forumotion.com/

Back to top Go down

Solved Re: Widget Javascript codes keep interracting

Post by nextlevelgaming Sun 30 Sep 2012 - 9:35

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...
nextlevelgaming
nextlevelgaming
Forumember

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

http://www.easybbtutorials.forumotion.com

Back to top Go down

Solved Re: Widget Javascript codes keep interracting

Post by Ravenstar Sun 30 Sep 2012 - 9:50

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
Ravenstar
Ravenstar
Forumember

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

http://warriorclan.forumotion.com/

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum