Fill input type text

  Kiến thức lập trình

I’m not able to fill the input with the res.
Where am I going wrong? I need that when loading the page
the script below fills the input id=”code” with
o var res. Could anyone help me resolve this?
I thank the attention.

<script type="text/javascript">
const agora = moment();
var ano = (agora.format("YYYY"));
var dia = (agora.format("DD"));
var mes = (agora.format("MM"));
var res = (ano + "/" + "sigla" + dia + mes + "_01")
$('#codigo').val(res);
</script>

<input type="text" id="codigo">

New contributor

Cleyton Ramos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT