-1

for example i need to check DHL tracking number and i asking user to enter their tracking number to check it. here is input:

Name: <input type="text" id="myText" >
<button onclick="myFunction()">check tracking</button>

And DHL making it adding code tu url for example: https://nolp.dhl.de/nextt-online-public/en/search?piececode= and plus tracking codehere. The demo url is this: https://nolp.dhl.de/nextt-online-public/en/search?piececode=48484848484848484

Here is Javascript:

function myFunction() {
var inputed_code = document.getElementById("myText").value ;
var dhlurl = "https://nolp.dhl.de/nextt-online-public/en/search?piececode="
var new_url = dhlurl + inputed_code ;
    window.open("new_url", "_blank");
}

But it doesn't url as it is needed :(

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
fefe
  • 17
  • 3

1 Answers1

1

That's because you're using "new_url", which is a literal strting, instead of new_url, the variable

function myFunction() {
var inputed_code = document.getElementById("myText").value ;
var dhlurl = "https://nolp.dhl.de/nextt-online-public/en/search?piececode="
var new_url = dhlurl + inputed_code ;
window.open(new_url, "_blank");

}

vityavv
  • 1,482
  • 12
  • 23