使多个链接可见 JavaScript
making multiple links visible javascript
本文关键字:JavaScript 链接 更新时间:2023-09-26
可以一次显示多个链接吗?我的意思是在我的以下代码中,当我在文本字段中输入project
并按提交按钮时,abc.htm
链接变得可见。现在,我希望当我在文本字段中输入project
并按提交按钮时abc.htm
和xyz.htm
和cold.htm
链接变得可见。在文本字段中写下的情况相同。
<html>
<head>
<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")
document.getElementById('project_link').style.display = 'block';
else if (text_form.text_name.value == "under")
document.getElementById('construction_link').style.display = 'block';
else
alert("Invalid keyword!");
return (false);
}
-->
</script>
</head>
<body>
<form name="text_form" method="get" action="#"
onsubmit="return Blank_TextField_Validator()">
<a id='project_link' href='abc.htm' style='display: none;'>project</a>
<a id='construction_link' href='New Text Document (3).htm' style='display: none;'>construction</a>
<input type="text" name="text_name" >
<input type="submit" value="Submit">
</form>
</body>
</html>
这是我尝试过的:
if (text_form.text_name.value == "project")
document.getElementById('project_link').style.display = 'block';
document.getElementById('project_link_1').style.display = 'block';
<form name="text_form" method="get" action="#" onsubmit="return Blank_TextField_Validator()">
<a id='project_link' href='abc.htm' style='display: none;'>project</a>
<a id='project_link_1' href='xyz.htm' style='display: none;'>projects</a>
<a id='construction_link' href='New Text Document (3).htm' style='display: none;'>construction</a>
更改
if (text_form.text_name.value == "project")
document.getElementById('project_link').style.display = 'block';
document.getElementById('project_link_1').style.display = 'block';
自
if (text_form.text_name.value == "project") {
document.getElementById('project_link').style.display = 'block';
document.getElementById('project_link_1').style.display = 'block';
}
顺便说一句,我真的同意评论员对原始问题的看法:你应该在发布有关它的问题之前学习JavaScript。你需要知道你实际上在做什么才能成功。
相关文章:
- JavaScript链接在点击时不起作用;函数在页面加载时工作
- 使用Java从javascript链接获取html更改
- 动态虚拟目录和外部 JavaScript 链接
- Web 地址虚拟目录会断开外部 JavaScript 链接,因此找不到文件
- Datatable Javascript链接在第2页不起作用
- 如何将href与javascript链接
- Javascript链接和变量替换
- Javascript链接使目标为空
- 外部JavaScript链接不起作用
- 鼠标光标改变Javascript链接的DIV
- Action使用Javascript链接并将值传递给控制器
- Javascript链接-试图设置元素值-奇怪的行为chrome&安卓
- 如何在没有onClick的情况下使用Javascript链接
- Javascript根据屏幕大小编写新的Javascript链接
- 更新用户's使用PHP或JavaScript链接
- JavaScript链接提取器
- javascript链接使页面在单击时向上
- 使用javascript链接样式
- 触摸设备的JavaScript链接预览
- Jquery javascript 链接含义