escape ' ' in " " (in a string!)

E

Emre Avsar

hi guys..

i have this code:

var myhtml = "<tr>" +
"<th style='color:#006296'>" +
standortname +
"</th>" +
"<th>" +
"Standort von: " +
"</th>" +
"<th>" +
"Anzeigen: <input type='checkbox' class='checkbox' name='show'
value='show' onClick='" + createMarker + "'/>" +
"</tr>"

in the checkbox, i want a onClick event:
alert('hello');

i've tried id with doing a variable:
var createMarker = "alert(\'hello\')";
but it doesnt work.

any help?
 
G

Garrett Smith

Code:
Please always carefully format code so that it wraps at about 72 chars.
http://jibbering.com/faq/#posting
[QUOTE]
If you'd simply generate the DOM with createElement/appendElement,[/QUOTE]

(you probably meant appendChild).

you[QUOTE]
could easily attach a Listener to the checkbox -[/QUOTE]

function createMarker(ev){
alert([ this, ev || window.event ]);
}
var cb = document.createElement("input"),
aForm = document.forms[0];
cb.type = "checkbox";
cb.onclick = createMarker;
aForm.appendChild(cb);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,083
Messages
2,570,591
Members
47,212
Latest member
RobynWiley

Latest Threads

Top