Web开发的新手。我希望能够添加一个额外的urlstring来基于一个唯一的搜索栏过滤多个iframe。 “ PN”是我想用来控制它的变量。我希望能够添加第二个urlstring变量来过滤单独的iframe。
<script>
function myFunction2() {
var pn = document.getElementById('pnbox').value;
var urlstring2 = "https://example.com/?
col1=Part%20Number&op1=EQ&val1="+pn+"#";
alert(urlstring2);
document.getElementById('myiframe5b').src=urlstring2;}
function UserAction() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
alert(this.responseText);
}
};
xhttp.open("POST", "Your Rest URL Here", true);
xhttp.setRequestHeader("Content-type", "application/json");
xhttp.send("Your JSON Data Here");}
</script>
<body>
<div class="container">
<fieldset>
<p>
<select id = "taskList" class="taskList"
onchange="showhide(this)">
<option value = "">What would you like to know..</option>
<option value = "1">Question 1?</option>
<option value = "2">Question 2?</option>
<option value = "3">Question 3?</option>
<option value = "4">Question 4?</option>
<option value = "5">Question 5?</option>
<option value = "6">Question 6?</option>
<option value = "7">Question 7?</option>
<option value = "2">Question 8?</option>
<option value = "2">Question 9?</option>
<option value = "2">Question 10?</option>
</select>
Serial Number Prefix: <input class="snbox" type="text" name =
"snbox" id="snbox"><button onclick="myFunction()">Select</button>
Part Number: <input class="pnbox" type="text" name = "pnbox"
id="pnbox"><button onclick="myFunction2()">Select</button>
</p>
</fieldset>
</form>
</div>
<div class="answer5 answers" style="width:100%;height:500px;display:none">
<div id="value5">Please enter a serial number prefix</div>
<iframe src="https://example.com/" width="100%" height="500" style="border-
color:#666666" id="myiframe5" allowfullscreen></iframe>
<iframe src="https://example.com/" width="100%%" height="500" style="border-
color:#666666" id="myiframe5a" allowfullscreen></iframe>
<iframe src="https://example.com/" width="100%" height="500" style="border-
color:#666666" id="myiframe5b" allowfullscreen></iframe>
</div>