我在javascript中有一个查询字符串,如下所示:Default.aspx?7KCN0008-001当我尝试将7KCN0008-001插入到我获得的文本框中时[对象对象]我怎么能把这里的值放在这里的文本框是我的:如何在javascript中获取值查询字符串并将其放入文本框中
function test() {
var urlParams;
(window.onpopstate = function() {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl,"")); },
query = window.location.search.substring(1);
urlParams = {};
while (match = search.exec(query))
urlParams[decode(match[1])] = decode(match[2]);
})();
$('#txtStockCode').val(urlParams[decode(match[1])]);
}
还有一件事,如果我有这样的URL:Default.aspx?7KCN0008-001 SAVSS0.85B 2180 916941-000%20%20%20%20%20%20%20%20%20%20%20%20 %20%20%20%20%20%20%20%20%20 917418-060,我怎样才能把7KCN0008-001,SAVSS0.85B,2180,916941-000,917418-060放在自己的文本框中,比如6个文本框? – billah77
@ billah77,好的。你的意思是有六个值由空格分隔? (看起来有五个值。) – naota
我的坏有五个值 – billah77