VBProgramming VBProgramming - 3 months ago 7
Javascript Question

Cant put variable(string) in javascript innerhtml

How can I quote the

meni
variable correctly in the code below? It's currently producing
cancel(menu)
instead of
cancel('menu')


var meni='menu';

document.getElementById("modify_table"). rows.item(counter).cells[4].innerHTML="<a href='javascript:cancel("+meni+")'><b style='color:red;'>Cancel</b></a>";

Answer
document.getElementById("modify_table"). rows.item(counter).cells[4].innerHTML="<a href='javascript:cancel(\""+meni+"\")'><b style='color:red;'>Cancel</b></a>";