我所拥有的就是这个,但我从 java 脚本的下拉菜单中没有得到任何值来将其与字符串进行比较
// JavaScript Document
var singleMulticontainer = document.getElementById("singleMultiContainer");
var singleMultiValue = singleMultiContainer.options[singleMultiContainer.selectedIndex].value;
var nextButton = document.getElementById("nextButton");
var multipleSetWindow = "window.location='multiSet.html'"
if(singleMultiValue == "multi"){
document.getElementById("nextButton").setAttribute("data-location", "multiSet.html");
}
else{
alert("notworking");
}
Run Code Online (Sandbox Code Playgroud)
下拉菜单是这样的:如何从单个容器或多容器的选项中获取值?
<form id"suspendedProperties">
<p><h4>Select Station:
<select name="stationDropdown">
<option value="50028000">Tanama</option>
<option value="60008001">Example Riv1</option>
<option value="60008002">Example Riv2</option>
<option value="60008003">Example Riv3</option>
<option value="60008004">Example Riv4</option>
</select>
</h4></p>
<p>Select Sample Medium:
<select name="sampleMediumDropdown">
<option value="Wer">Wer</option>
<option value="WSQ">WSQ</option>
</select>
</p>
<p>Begin Date
<input type="date"/>
</p>
<p>Hydrologic Event: <select name="hydroEvent">
<option value="1">Example 1</option>
<option value="2">Example 2</option> …Run Code Online (Sandbox Code Playgroud) 我想将一个从表单中获得的数字转换为字符串并将其与另一个字符串组合,但我收到了:
windows.location='multiSet?type=multi'Number
Run Code Online (Sandbox Code Playgroud)
相反,我想得到这个:
windows.location='multiSet?type=multiNumber'
Run Code Online (Sandbox Code Playgroud)
请注意,差异是'标记在之前的位置,Number我希望它在之后...
我在其他帖子中看到的是如何将字符串作为数字而不是反之亦然.
var singleMultiContainer = document.getElementById("singleMultiContainer");
var singleMultiValue = singleMultiContainer.value;
var nextButton = document.getElementById("nextButton");
var multipleSetWindow = "window.location='multiSet.html?type=multi'";
var singleSetWindow = "window.location='SampleInfo.html?type=single'";
var containerCuantity = document.getElementById("containerCuantity");
function setContainers(){
singleMultiValue = singleMultiContainer.value;
containerCuantityValue = parseInt(containerCuantity.value);
if (singleMultiValue == "multi"){
//alert("Multi");
document.getElementById("nextButton").setAttribute("onclick", multipleSetWindow+containerCuantityValue);
} else if (singleMultiValue == "single") {
document.getElementById("nextButton").setAttribute("onclick", singleSetWindow);
}
}
singleMultiContainer.onchange = function(){
setContainers();
}
Run Code Online (Sandbox Code Playgroud)