By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,553 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

how to encode this line

Claus Mygind
100+
P: 571
It appears I have run out of delimiters, so there must be a way around this coding problem.

I am creating some dynamic content, into which I want to add a couple of variables. I have tried escaping the " (see below) and also tried the [ ] (not sure if square brackets can be used as delimiters).

So how to code this? And if the suggestion is to do an evaluate, please provide and example.

Expand|Select|Wrap|Line Numbers
  1. td.innerHTML = '<a href="#" onclick = "showDetail(\"'+chkForDay+'\",\"'+chkForDay+'\");">show detail</a> '
  2.  
Jan 27 '09 #1
Share this Question
Share on Google+
2 Replies


acoder
Expert Mod 15k+
P: 16,027
Either use escaped single quotes (as opposed to the double ones) or use a string (with the quotes) and just include that instead, e.g.
Expand|Select|Wrap|Line Numbers
  1. var str = "'test'";
  2. something.innerHTML = '<a href="#" onclick = "showDetail('+str+');">show detail</a> ';
Jan 27 '09 #2

Claus Mygind
100+
P: 571
Well as it often seems my problems lay in another location. The parameter that was being stored with the "onclick" event handler was being constantly updated as it cycled through my loop. So I assigned the value to the id of the anchor and was able to resolve my problem

Expand|Select|Wrap|Line Numbers
  1. for ( var employee in aWeeklyTime )
  2. {
  3.    for ( var dayOfWeek in aWeeklyTime[employee] )
  4.    {
  5.      td.innerHTML = '<a href="#" id= "'+employee+'"  onclick = "showDetail(this.id,chkForDay);">show detail</a> '
  6.  
  7.    }
  8. }
  9.  
Jan 27 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.