我想將一個參數傳遞給一個在tag之外定義的javascript函數,但是當我嘗試在javascript函數中使用它時,它顯示undefined.i使用警報在jsp頁面和SCRIPT關閉......請幫助如何將參數傳遞給在窗體標籤外定義的javascript函數?
<html>
<script type="text/javascript">
js_valueDate = '<%=valueDate%>';
alert(js_valueDate) **//displays correct value here**
</script>
<body>
<form>
....some html...
<td width=27%><input type=text name="ValDate"
onchange = "javascript:validateDate(document.f1.ValDate,js_valueDate);"></td>
......some html....
</form>
</body>
</html>
,這是我的javascript函數:
function validateDate(ValDate,origValDate) {
var valueDate=ValDate.value;
var OrigvalueDate=origValDate.value;
confirm(valueDate);
confirm(OrigvalueDate); **//displays undefined here**
var hh=replaceAll(valueDate,'-','');
confirm(hh);
if (replaceAll(valueDate,"-","")<=valueDate<=replaceAll(OrigvalueDate,"-","")) {
return true;
} else {
alertPopup("Please enter a valid value date");
document.f1.ValDate.focus();
return false;
}
}
只是把包含表單標籤之前,在頁面頂部的JavaScript函數的腳本標籤,並檢查.. – tarzanbappa 2014-12-04 06:39:55