Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用javascript在页面URL中添加多个变量_Php_Javascript_Url_Variables - Fatal编程技术网

Php 使用javascript在页面URL中添加多个变量

Php 使用javascript在页面URL中添加多个变量,php,javascript,url,variables,Php,Javascript,Url,Variables,因为我对php和javascript的使用还比较陌生,所以在尝试在URL中添加多个变量时遇到了这个问题 我使用以下脚本: <script> function refresh() { var PCWDE = document.getElementById("PC"); var NMWDE = document.getElementById("naam"); var VNMWDE = document.getElementById("voornaam"); var ONDWDE

因为我对php和javascript的使用还比较陌生,所以在尝试在URL中添加多个变量时遇到了这个问题

我使用以下脚本:

<script>
function refresh() {
 var PCWDE = document.getElementById("PC");
 var NMWDE = document.getElementById("naam");
 var VNMWDE = document.getElementById("voornaam");
 var ONDWDE = document.getElementById("onderneming");
 var BTWWDE = document.getElementById("btwnummer");
 var LNDWDE = document.getElementById("land");


        this.document.location.href = "http://example.com/form.php?PCS=" + PCWDE.value "&nm=" + NMWDE.value "&vnm=" + VNMWDE.value "&ond=" + ONDWDE.value "&btw=" + BTWWDE.value "&lnd=" + LNDWDE.value;

}
</script>    
否则就不行了。“onblur”事件无法工作,或者脚本无法运行


有没有一种方法可以像我现在做的那样将多个变量添加到URL中?

您忘记了加号。这是一个语法错误,如果打开错误控制台,应该会看到错误消息。(在firefox上按control-shift-j)

应该是:

this.document.location.href = "http://example.com/form.php?PCS=" + PCWDE.value + "&nm=" + NMWDE.value + "&vnm=" + VNMWDE.value + "&ond=" + ONDWDE.value + "&btw=" + BTWWDE.value + "&lnd=" + LNDWDE.value;
 this.document.location.href = "http://example.com/form.php?PCS=" + PCWDE.value;
this.document.location.href = "http://example.com/form.php?PCS=" + PCWDE.value + "&nm=" + NMWDE.value + "&vnm=" + VNMWDE.value + "&ond=" + ONDWDE.value + "&btw=" + BTWWDE.value + "&lnd=" + LNDWDE.value;