Forums

RS-Linkify Thread is sticky

Quick find code: 261-262-33-65181208

Amaethwr
Aug Member 2008

Amaethwr

Posts: 14,634 Opal Posts by user Forum Profile RuneMetrics Profile
Morgan said :
HTTP://puu.sh/9HisK.jpg
Wow this looks delicious :X

Haven't checked Off Topic in ages, now.. How's things?

+ Can I have a code for this please, Indy? :)

http://puu.sh/9IsFd/6bc6723e1b.png

E:

Keighlea said :
HTTP://puu.sh/9FBL3/467cc12331.png

Amaoreo is bullying me... I vote to block him off from all caffeine access :( (!!­­­­
I only have tea anyway :P + I could go without..!
Selective Completionist

24-Jun-2014 20:53:38 - Last edited on 24-Jun-2014 20:57:39 by Amaethwr

Was Zeus

Was Zeus

Posts: 22,388 Opal Posts by user Forum Profile RuneMetrics Profile
Can I have a code for this please?

http://i.imgur.com/4XwBYd3.png

Thanks
ZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZEUSZE

24-Jun-2014 21:16:52

Morgan

Morgan

Posts: 36,054 Sapphire Posts by user Forum Profile RuneMetrics Profile
I'm sorry I'm sort of... hijacking this thread again :( but you guys are better than me at this!

p.s: Keep in mind I'm EXTREMELY new at Javascript (Been messing around for a few minutes)

<!DOCTYPE html>
<html>
<body>

<p>Please input the right code for your cookies:</p>

<input id="cookieGiver" type="text">

<button type="button" onclick="giveCookies()">Get your cookies!</button>

<p id="textCookie"></p>

<script>
function giveCookies() {

var val = document.getElementById("cookieGiver&quot ;) .value;
var elem = document.getElementById("textCookie&quot ;) ;
var counter = document.getElementById("counter&quot ;) ;
var cookieCounter = 0;


if(val.trim() == "Gib&quot ;) {
cookieCounter += 50;
elem.innerHTML = "*gives 50 cookies* You now have " + cookieCounter + " cookies.";
} else {
elem.innerHTML = "Invalid code";
}
}
</script>

</body>
</html>

So the problem here is that var cookieCounter doesn't go up if I input "Gib" after having done it once. Although if I input an invalid code, the program still detects I did and changes "elem" as such.

What's going on :(

25-Jun-2014 02:44:40 - Last edited on 25-Jun-2014 02:45:08 by Morgan

Indecent Act

Indecent Act

Posts: 7,456 Rune Posts by user Forum Profile RuneMetrics Profile
­­­­DangerrZzone­­ http://www.indecentcode.com/rslinkify_images/10441.png ­­10441­­­­

----------------------------------------------------------------------------------

­­­­Amaethwr­­ http://www.indecentcode.com/rslinkify_images/10442.png ­­10442­­­­
Hiya Amaethwr, Everything is good here and it's nice to see you found your way into Off Topic :)

----------------------------------------------------------------------------------

­­­­Zeus­­ http://www.indecentcode.com/rslinkify_images/10443.png ­­10443­­­­
I like the new look Zeus :)

----------------------------------------------------------------------------------

@Morgypie, this may not be the best way to do it, but it's easy to see how different variables work in this example. Just one little line of code needs to be moved :)

­­ http://puu.sh/9IVG8.png ­­

Each time your function runs, the counter is being declared, assigned zero then has 50 added to it (so it will always be 50). By declaring the counter before the function makes it global and means it can used, increased, decreased, etc, without having to re-declare it.

Basically now when the page loads, counter is now declared before your function has run. Your function will use the last known value of the counter and increment that by 50 :)

25-Jun-2014 04:04:32 - Last edited on 25-Jun-2014 04:30:50 by Indecent Act

Bertie

Bertie

Posts: 889 Gold Posts by user Forum Profile RuneMetrics Profile
Sorry I'm not sure about how to paste in this chat head and for it to still have trans so is a link ok? Thanks a lot!

http://img2.wikia.nocookie.net/__cb20140602190206/runescape/images/e/ee/Mono_chathead.png
Nothing interesting happens.

25-Jun-2014 11:20:01

Quick find code: 261-262-33-65181208 Back to Top