Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/439.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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
Javascript-根据所选选项自定义url_Javascript_Url_Select_Parameters - Fatal编程技术网

Javascript-根据所选选项自定义url

Javascript-根据所选选项自定义url,javascript,url,select,parameters,Javascript,Url,Select,Parameters,我尝试了几个JS代码,但都做不到。 请帮忙。我解决了这个问题:D 这是解决办法 http://link.com/?brandovi=sava&sezona=zima&vrstaVozila=4x4 功能子图(表格){ var brandovi=document.getElementById(“brandovi”); var brand=brandovi.options[brandovi.selectedIndex].value; var vrsteVozila=documen

我尝试了几个JS代码,但都做不到。
请帮忙。

我解决了这个问题:D

这是解决办法

http://link.com/?brandovi=sava&sezona=zima&vrstaVozila=4x4

功能子图(表格){
var brandovi=document.getElementById(“brandovi”);
var brand=brandovi.options[brandovi.selectedIndex].value;
var vrsteVozila=document.getElementById(“vrsteVozila”);
var vrsta=vrsteVozila.options[vrsteVozila.selectedIndex].value;
var radios=document.getElementsByName(“季节”);
对于(变量i=0,长度=radios.length;i

请给我们看一些您尝试过的代码。。。但基本上,如果你使用
GET
而不是
POST
,用适当的名称修改你的html,并将你的
action
更改为“”,它会起作用…我尝试了在internet上找到的一些,这是我第一次使用javascript,所以我知道的不多。所以我想是时候试着来这里展示一些代码了,当你尝试。。。这就是你学习的方法:-)函数品牌(obj){var brand=obj.options[obj.selectedIndex];如果(brand.value!=“nothing”){window.location=document.URL+'/?brandovi='+brand.value;}}我定制了这个,但它可以更改所选内容,我想在点击按钮时进行更改。这只是一个选择选项,我想做三个。
http://link.com/?brandovi=sava&sezona=zima&vrstaVozila=4x4
<script type="text/javascript">
function submitUrl(form){
    var brandovi = document.getElementById("brandovi");
    var brand = brandovi.options[brandovi.selectedIndex].value;
    var vrsteVozila = document.getElementById("vrsteVozila");
    var vrsta = vrsteVozila.options[vrsteVozila.selectedIndex].value;

    var radios = document.getElementsByName('season');

    for (var i = 0, length = radios.length; i < length; i++) {
    if (radios[i].checked) {
    var sezona = radios[i].value;
}
    else{
        var sezona = '';
    }
}  
    window.location = 'http://localhost/wordpress/' +  '?brandovi=' + brand + '&sezona=' + sezona + '&vrstaVozila=' + vrsta;
}