我想将日期和时间选择器中的值作为参数传递给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不包含日期值。
答案 0 :(得分:3)
我试图重现这个场景,它完全适合我: -
<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>