Javascript Tapestry表单提交问题

时间:2016-12-12 13:07:17

标签: javascript

所以我已经发送了一些HTML上传到我们的网站,基本上它是一个登录表单,但是在浏览器中按下时,“登录”按钮不会执行任何操作。我看到它正在使用“javascript:tapestry.form.submit”来使用程式化的按钮图像(img src =“images / submit.png”alt =“submit”)提交表单,我认为这可能是问题。< / p>

当我使用(输入类型=“提交”值=“登录”/)将其从此按钮更改为标准按钮时,它可以正常工作。是否有人可以想到为什么这个按钮可能导致问题而不是浏览器中的负载?如果您输入详细信息并按回车键,则表单有效。

    public IEnumerable<Record[]> GetRecordsInRange(DateTime startDate, DateTime endDate)
    {
        while(startDate <= endDate)
        {
            // This hard-coded stuff should be replaced with something prettier but that's off topic and comes down to your implementation and the meaning of QueryTypes
            // I choose to isolate it to the delegates variable to make it easy to rewrite and perhaps instantiate it from a function
            var delegates = new Func<Record[]>[] 
            {
                ()=>ExecuteQueryAPI(startDate, QueryTypes.A),
                ()=>ExecuteQueryAPI(startDate, QueryTypes.B),
                ()=>ExecuteQueryAPI(startDate, QueryTypes.C)
            };

            foreach(var d in delegates)
            {
                Record[] output;
                try
                {
                    output = d();
                }
                catch
                {
                    yield break;
                }
                yield return output;
            }

            startDate = startDate.AddDays(1);
        }
    }

1 个答案:

答案 0 :(得分:0)

继上述评论之后,我们的真正目标是更改提交按钮的外观,而不是向图像添加提交行为。我们可以用CSS做到这一点。

#loginForm > input[type="submit"] {
  width:60px;
  height:60px;

  // transparent background colour
  background-color: rgba(0,0,0,0);

  // allows the background to resize when you change width/height
  background-size:100% 100%;

  // use your submit image
  background-image: url("images/submit.png");

  // remove default button border
  border:none;

  // make a nicy pointy cursor
  cursor:pointer;
}

我已从HTML中删除了锚点和图片,并在提交按钮中添加了一个空白值,因此我们的背景图片上没有显示任何文字。

<div id="loginPanel">
    <div class="text">
        <p class="loginText">Welcome</p>
        <p class="loginText">Log-in to place your order</p>
    </div>
    <form method="post" action="http://coreprint.net/aspire/Login,loginForm.sdirect" id="loginForm">
        <div style="display:none;" id="loginFormhidden">
            <input type="hidden" name="formids" value="If_0,If_2,username,password,loginButton,If_4" />
            <input type="hidden" name="seedids" value="" />
            <input type="hidden" name="submitmode" value="" />
            <input type="hidden" name="submitname" value="" />
            <input type="hidden" name="If_0" value="F" />
            <input type="hidden" name="If_2" value="F" />
            <input type="hidden" name="If_4" value="F" />
            <input type="hidden" name="Hidden" id="Hidden" value="X" />
        </div>

        <table>
            <tr>
                <td>Username</td>
                <td><input type="text" name="username" value="" id="username" size="30" /></td>
            </tr>
            <tr>
                <td>Password</td>
                <td><input type="password" name="password" value="" id="password" size="30" /></td>
            </tr>
        </table>

        <input type="submit" value="" />
    </form>
</div>

Working example here