Javascript question

Gezza

Expert Member
Joined
Aug 18, 2009
Messages
2,094
Because we here at MyBroadband are smarter

Questionable :D

You mean to check for answers before posting here ? I did.
If you mean to post the question on S.O., because it's a schlep.

Plus, I'm actually more interested in why my original approach (to which S.O. hinted) did not work than an actual solution.

Fair enough. I've asked a couple of questions on Stack, I don't mind the way you need to ask them (Include code etc) as a few times I realised my mistake before I post.

Rarely happens that my questions have not been answered already.
 

battletoad

Expert Member
Joined
Mar 10, 2009
Messages
1,451
Plus, I'm actually more interested in why my original approach (to which S.O. hinted) did not work than an actual solution.

I'll take a stab.. It's probably this:
Code:
var f = "javascript:ClickFunction("+userid+");";
Which would resolve to
Code:
...ClickFunction(someId);
...instead of this, which is what you want...
Code:
...ClickFunction([b]'someId'[/b]);
In the first case, you're passing a variable called someId, which is undefined. Second case, encapsulate the double quotes with single quotes and JS will pass the actual string.
 

etienne_marais

Honorary Master
Joined
Mar 16, 2008
Messages
15,093
I know you probably don't have the luxury, since you said you are editing on the server using vi, but the developer console in Chrome is really great for Javascript issues. It even has step debugging - Javascript has notoriously bad error messages and the developer console has saved me many hours

Thanks, I'm testing with Chrome and the console now. As said, webdev is not my forte and can't dig to deep as I'm developing a library for frontend developer who will do the nitty gritty for a once of project, but I find I actually enjoy aspects of it.
 
Top