[Fixed]-Replacing two variables after filling a form

1👍

The syntax of setAttribute is

element.setAttribute(name, value);

You are calling it with 3 arguments, so the third one gets ignored.

document.getElementById("link")
  .setAttribute("href", 
                url.replace(/11-11-1111/, from),
                url.replace(/12-12-1212/, to)
  );

This should do it

var url = '{% url 'logistyka_tabela_brakow.views.report_from_to' '11-11-1111' '12-12-1212' %}';
url = url.replace(/11-11-1111/, from);
url = url.replace(/12-12-1212/, to);
document.getElementById("link").setAttribute("href", url);
👤C14L

Leave a comment