0
有沒有一種方法,而不是打開新頁面上的鏈接,下面的代碼可以使鏈接在同一頁面上可見?例如,如果我在文本字段中輸入「project」,然後按提交按鈕,則頁面上將顯示鏈接,即「project.htm」。如果我在文本框中寫下「下」並按提交按鈕,則underconstruction.htm鏈接變得可見。文本框使鏈接可見使用if else語句,javascript
<script Language="JavaScript">
<!--
function Blank_TextField_Validator() {
// Check the value of the element named text_name from the form named text_form
if (text_form.text_name.value == "") {
// If null display and alert box
alert("Please fill in the text field.");
// Place the cursor on the field for revision
text_form.text_name.focus();
// return false to stop further processing
return (false);
}
// If text_name is not null continue processing
if (text_form.text_name.value == "project")
window.open('project.htm');
else if (text_form.text_name.value == "under")
window.open('underconstruction.htm');
else
alert("Invalid keyword!");
return (true);
}
-->
</script>
可以請你寫出完整的代碼,因爲我沒有得到在哪裏添加的標記部分。 –
@JavariaShah這只是與你的標記的其餘部分(無論哪裏**
你的意思是?它不在這裏工作。
<形式名稱= 「text_form」 方法= 「GET」 行動= 「#」 的onsubmit = 「返回Blank_TextField_Validator()」> project construction <輸入類型=「提交」值=「提交」> –