[英]Based on input selected redirect to new html page on button click
I am new to javascripts. 我是javascripts的新手。 Based on the input selected from the drop downlist I need to redirect to new html page once i click the next button. 根据从下拉列表中选择的输入,我需要在单击下一个按钮后重定向到新的html页面。
...
<p>Application Type 
<select id = "aList" name="selection">
<option value = "">---Select Value---</option>
<option value = "New_req_p2_web.html">External Web Application</option>
<option value = "New_req_p2_web.html">Internal Web Application</option>
<option value = "New_req_p2_mob.html">Mobile Application</option>
<option value = "New_req_p2_net.html">Network</option>
</select>
</p>
<button type="submit" id="next" onclick="WinOpen()">Next</button>
....
<script type="text/javascript">
function WinOpen() {
var url=document.redirect.selection.value
document.location.href=url
}
</script>
...
You can do something like this: 你可以这样做:
You will need to make sure the path/value is correct for your htmlpage based on the current page your on, so the values may need to change to something like: ./New_req_p2_web.html
您需要根据当前页面确定htmlpage的路径/值是否正确,因此值可能需要更改为: ./New_req_p2_web.html
<p>Application Type</p>
<select id="aList" name="selection">
<option value="">---Select Value---</option>
<option value="New_req_p2_web.html">External Web Application</option>
<option value="New_req_p2_web.html">Internal Web Application</option>
<option value="New_req_p2_mob.html">Mobile Application</option>
<option value="New_req_p2_net.html">Network</option>
</select>
<button type="submit" id="next" onclick="WinOpen()">Next</button>
<script type="text/javascript">
//THIS WILL OPEN IN A NEW WINDOW/TAB
function WinOpen() {
var url = $('#aList').val();
window.open(url);
}
//THIS WILL OPEN ON ITS SELF - if you use this remove the onclick for the button.
$('#next').click(function () {
var url = $('#aList').val();
window.open(url, "_self");
});
</script>
Your path will need to be correct for the value, what i mean by this is if this file is in your desktop folder then your 'New_req_p2_web.html' will have to be in the same folder unless you change the pathing of your value. 你的路径需要正确的值,我的意思是,如果这个文件在你的桌面文件夹中,那么你的'New_req_p2_web.html'将必须在同一个文件夹中,除非你改变你的值的路径。
The updated code here, I hope it's useful for you. 这里更新的代码,我希望它对你有用。
Thanks 谢谢
<p>Application Type 
<select id="aList" name="selection">
<option value="">---Select Value---</option>
<option value="New_req_p2_web.html">External Web Application</option>
<option value="New_req_p2_web.html">Internal Web Application</option>
<option value="New_req_p2_mob.html">Mobile Application</option>
<option value="New_req_p2_net.html">Network</option>
</select>
</p>
<button type="submit" id="next" onClick="WinOpen();">Next</button>
<script type="text/javascript">
function WinOpen() {
var url = document.getElementById("aList").value;
document.location.href = url;
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.