0

有没有一种方法可以使链接在同一页面上可见,而不是在新页面上打开链接?例如,如果我在文本字段中输入“项目”并按下提交按钮,则project.htm链接会在页面上可见;如果我在文本框中写下“under”并按下提交按钮,那么underconstruction.htm链接就会变得可见。

    <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>
4

1 回答 1

0

不确定这是否是一个技巧问题..你不能这样做吗?

脚本

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);

标记

<a id='project_link' href='project.htm' style='display: none;'>project</a>
<a id='construction_link' href='underconstruction.htm' style='display: none;'>construction</a>
于 2012-05-02T08:22:54.653 回答