使用输入标记生成URL

问题描述 投票:-1回答:1

例如,我需要检查DHL跟踪号码,并要求用户输入他们的跟踪号码进行检查。这是输入:

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

DHL使其添加代码调用网址,例如:https://nolp.dhl.de/nextt-online-public/en/search?piececode=和plus跟踪代码。演示网址是:https://nolp.dhl.de/nextt-online-public/en/search?piececode=48484848484848484

这是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");
}

但它不需要网址:(

javascript html
1个回答
1
投票

那是因为你正在使用qazxsw poi,这是一个文字字符串,而不是qazxsw poi,变量

"new_url"

}

© www.soinside.com 2019 - 2024. All rights reserved.