【问题标题】:How can I replace button as link?如何将按钮替换为链接?
【发布时间】:2011-03-29 12:14:43
【问题描述】:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>  
    <head>  
        <title>Register</title>  
    </head>  
    <body>  
        <h1>Register</h1>
        <div>
            <form:form method="post" action="${flowExecutionUrl}" commandName="userForm">
                <div style="width:240px">

                    <div>
                        <div>First Name:</div>
                        <div ><form:input path="name"/></div>

                    </div>
                    <div>
                        <div>Last Name:</div>
                        <div ><form:input path="surname"/></div>
                    </div>
                    <div>
                        <div>E-mail:</div>
                        <div ><input type="text" name="email" /></div>
                    </div>
                    <div>
                        <div>Username:</div>
                        <div ><input type="text" name="username" /></div>
                    </div>
                    <div>
                        <div>Password:</div>
                        <div ><input type="password" name="password" /></div>
                    </div>
                    <div>
                        <div>Confirm Password:</div>
                        <div ><input type="password" name="confirmPassword" /></div>
                    </div>
                    <div>
                        <div>Country:</div>
                        <div>
                            <select>
                                <c:forEach items="${countryList}" var="countryVar">
                                <option value="${countryVar}">${countryVar}.code</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div>
                        <div>Phone numbers:</div>
                        <div>
                            <input name="deleteNumber" type="hidden" id="deleteNumber" />
                            <c:forEach var="phoneNumber" items="${userForm.phoneNumbers}" varStatus="varStatus">
                                <form:input path="phoneNumbers[${varStatus.index}]" />
                                <input type="hidden" name="_eventId_deletePhoneNumber" onclick="document.getElementById('deleteNumber').value = ${varStatus.index};" value="Delete" />
                            </c:forEach>
                        </div>
                    </div>
                    <div>
                        <div></div>
                        <div>
                            <div>
                                <input type="submit" name="_eventId_submitRegistration" value="Submit" />
                            </div>
                            <div>
                                <input type="submit" name="_eventId_addPhoneNumber" value="Add phone number" />
                            </div>
                            <div>
                                <div style="padding-left:5px">
                                    <button onclick="window.location='${flowExecutionUrl}&_eventId=cancelRegistration'">Cancel</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form:form>

        </div>  
    </body>  
</html> 

如何替换“_eventId_addPhoneNumber”和“_eventId_deletePhoneNumber”按钮?

【问题讨论】:

    标签: model-view-controller spring jsp spring-webflow


    【解决方案1】:

    有很多方法可以做到这一点。最简单的方法是将它们从您的 GUI 中删除,添加链接并编写 javascript。

    【讨论】:

    • @user612925 ,Link,然后编码 doSomething()
    • 我必须提交带参数的表单,我该怎么办?
    • 首先了解 Viewstates(.Net) 和使用 javascript 发布表单。提交表单就像调用 document.form.submit() 一样简单,但我的印象是您需要学习基本的 get、post、submit、javascript 和 jquery。 ASP.net 让您的事情变得更轻松,但这并不意味着您可以跳过 javascript 和基本的 html 表单提交。
    猜你喜欢
    • 2014-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-04
    • 2015-05-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多