[英]How to pass javascript textBox value to URL as parameter
我想將日期和時間選擇器中的值作為參數傳遞給URL。 這就是我所擁有的:
<div style="text-align:left; margin:8px 5px auto;">
<label for="dt_id">Please enter a date and time </label>
<input type="Text" id="dt_id" maxlength="25" size="25"/>
<img src="../../js/datetimepicker/images2/cal.gif" onclick="javascript:NewCssCal('dt_id','yyyyMMdd','arrow','true','24')" style="cursor:pointer"/>
<input type='button' onclick='setURL()' value='SUBMIT'>
</div>
<script>
var dt_value = document.getElementById("dt_id").value;
var sjdurl = "/path/script?datetime="+dt_value;
</script>
但是,URL不包含日期值。
我試圖重現這個場景,它完全適合我: -
<html>
<head>
<script>
function setURL(){
var dt_value = document.getElementById("dt_id").value;
//just test here ..what is coming..
alert(dt_value );
var sjdurl = "www.google.com?datetime="+dt_value;
popup = window.open(sjdurl,"popup"," menubar =0,toolbar =0,location=0, height=900, width=1000");
popup.window.moveTo(950,150);
}
</script>
</head>
<body>
<div style="text-align:left; margin:8px 5px auto;">
<label for="dt_id">Please enter a date and time </label>
<input type="Text" id="dt_id" maxlength="25" size="25"/>
<input type='button' onclick='setURL()' value='SUBMIT'>
</div>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.