/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Not Alerting

[url]http://pastebin.com/0YZNWj71[/url]

I’m not sure why I”m NOT getting my alert of the datastring? Anybody see why?

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@tpdietzJan 10.2011 — Appreciate the link, but it would be more helpful if you could point to the relevant lines of code, so we don't have to sift through all 300 of them.
Copy linkTweet thisAlerts:
@xtremer360authorJan 10.2011 — the alert is on line 90.
Copy linkTweet thisAlerts:
@tpdietzJan 10.2011 — For one thing, you're embedding PHP within the JavaScript and I don't see any PHP tags.

Also, many of the variables used in your dataString are declared within the 'for' loop and therefore have no scope outside where you use them to create dataString.
Copy linkTweet thisAlerts:
@xtremer360authorJan 10.2011 — I thought I covered all the php tags inside of my javascript. Where did I miss a pair.

Can you explain the second part of your reply more please.
Copy linkTweet thisAlerts:
@tpdietzJan 10.2011 — Well, someone else may need to answer the part about the php tags, but I'm assuming that the code at that link is HTML and any time you use PHP in the HTML you need to wrap in within <?php> <?> tags, as you did at the very beginning of the code. I don't see any of those tags in the javascript. If I am wrong about that, I apologize.

As for the second part of my reply, I presume you understand the concept of "scope" in javascript. If you declare a variable within a code block, if you try to access it outside of that block, it will be a different variable.

For example:

<i>
</i>{
var inside = "Hello";
}
document.write(inside);


will display nothing, since the outer "inside" is not the same as the inner "inside". You need declare the variable outside of the block in order to access it from outside of the block, like:

<i>
</i>var inside;
{
inside = "Hello";
}
document.write(inside);


This will display "Hello".
Copy linkTweet thisAlerts:
@xtremer360authorJan 10.2011 — Okay what do you suggest I do with it?
Copy linkTweet thisAlerts:
@tpdietzJan 10.2011 — Sorry, but if you don't understand the basics of scoping, you should find a good tutorial...One that I just found is at http://www.mredkj.com/tutorials/reference_js_intro_ex.html.
×

Success!

Help @xtremer360 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...