创建将用户带到不同页面的表单

create form that will take user to different page

本文关键字:表单 用户 创建      更新时间:2023-09-26

这听起来很简单,但我很难弄清楚。我对制作表格没有太多的知识,所以这也无济于事。以下是我希望发生的事情。

我想在表单上创建一个输入文本字段,来自公司的用户可以在其中输入公司名称。然后他们会点击提交。根据公司名称,将打开一个专为该公司设计的网页。

我只有大约5家公司和5个不同的网页,所以这不是真正的大。

我还需要一些东西,如果他们输入了错误的公司名称,它会让用户知道并选择退出表单或重试。

希望有人能帮我尽可能简单地做到这一点。

以下是入门的基本页面:http://jsfiddle.net/uaAXz/1/

你需要添加更多的逻辑来确定你要重定向到哪个webapge,并查看它是否是一家有效的公司。那就交给你吧。

$(document).ready(function() {
    $("#goButton").click(function() {
        var companyName = $("#companyName").val();
        // do stuff with the company name (see if it valid)
        alert("GO TO THE WEB PAGE FOR:" +  companyName );
        // go somewhere based off of the name
        //document.location = "http:''www.google.ca"
    });
});

(记住在脚本元素中扭曲它)

然后对于你的html,你需要开始的就是:

<input type="textfield" id="companyName" />
<br/>
<input type="button" id="goButton" value="GO" />

希望这能让你走上正轨:)

这比我想象的要困难得多。这是我的东西,你觉得行吗?。

    <script type="text/javascript" language="javascript"> 

$(document).ready(function){

$("#goButton").click(function() {
    var companyName = $("#companyName").val();
    // do stuff with the company name (see if it valid)
    alert("GO TO THE WEB PAGE FOR:" +  companyName );
    if (companyName = compa) 

//document.location="www.compa.html"

    if (companyName = compb) 

//document.location="www.compb.html"

    else 

//document.location="www.comp.html"

    // go somewhere based off of the name
    //document.location = "http:''www.google.ca"
});

});

我不知道你说的"把它包在脚本元素中"是什么意思。我在上面做了吗。

我对htlm文件没有问题。我对此很满意。

相关文章: