Teste ao escape de variavel

Valor num HTML com evento onclick. HTML é passado a uma função que depois insere o HTML no DOM.

by Salustiano Silva

HTML

<table>
    <thead>
        <tr>
            <th>Dia</th>
        </tr>
    </thead>
    <tbody>
        <tr id="minhaTr"></tr>
    </tbody>
</table>
<div id="popup" style="display:none" align="center" >
    <a onclick="close_popup()" href="#" style="float: right;">X</a>
    <br/>
    <label>POPUP</label>
    <p></p>
</div>
<div id="abc">Eu também estava escondida!</div>

CSS

#popup, #abc{
    display:none;
}

JavaScript

function close_popup() {
    document.getElementById('popup').style.display = 'none';
}

function open_popup(aff_j) {

    // fazer algo com o valor de "aff_j"
    alert("Clicou no dia: " + aff_j);
    var myPopup  = document.getElementById('popup');
    
    myPopup.insertAdjacentHTML('beforeend', '<div>'+aff_j+'</div>');

    document.getElementById('popup').style.display = 'block';
    document.getElementById('abc').style.display = 'block'; 
}

function disp (meuHtml) {
    document.getElementById("minhaTr").innerHTML = meuHtml;
}

// As variáveis que estás a utilizar
var colFerie = "black",
    colTexte = "white",
    aff_j    = 1;

// A chamada da tua função como tens na pergunta mas com adição do sugerido na minha resposta
disp("<TD class=j bgcolor='"+colFerie+"' align='center'><a onclick='javascript:open_popup(\""+aff_j+"\")' href='#'><FONT face='Arial' size='-1' color='"+colTexte+"'>"+aff_j+"</FONT></a></TD>");