在所附的图片中,每个按钮都是command submit按钮{brewery1,distributor1,…etc},并提交表单(http post方法)并在单击时加载到下一页。我想做的是在点击一个按钮时弹出一个对话框,要求用户确保提交表单。我已经检查了各种其他来源,但找不到任何合适的解决方案,因为表单已提交时,按钮被点击。如有任何帮助,我们将不胜感激[`提交按钮
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/jsf/html " xmlns:f="http://xmlns.jcp.org/jsf/core">
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="refresh" content="10"/>
<h:head profile="http://www.w3.org/2005/10/profile">
<h:outputStylesheet library="css" name="css_style.css"/>
<title>The Beergame New</title>
<link rel="icon"
type="image/png"
href="#{resource['images:MunichBrewery.png']}"/>
<link rel="icon" type="image/png" href="/favicon.png"/>
</h:head>
<h:body>
<h:form id="inputForm" class="input_form">
<meta http-equiv="Cache-Control" content="public"/>
<h2>Welcome to the Beer Game!<br/></h2>
<h:outputStylesheet library="css" name="css_style.css"/>
<h:graphicImage styleClass="TUMBrewery" url="#{resource['images:TUMBreweryBlue.png']}"
height="110"
alt="TUM Brewery"/>
<h:outputStylesheet library="css" name="css_style.css"/>
<h:graphicImage url="#{resource['images:MunichBrewery1.png']}"
alt="Munich Brewery"/>
<br/>What is your role? <br/>
<div id="button1-block">
<br/> <h:commandButton id="submit" value="Brewery 1" styleClass="button1">
<f:actionListener binding="#{loginweb.setNewUsernameAndCreateUser('Brewery1')}"/>
</h:commandButton>
<h:commandButton id="submit1" value="Distributor 1" styleClass="button1">
<f:actionListener binding="#{loginweb.setNewUsernameAndCreateUser('Distributor1')}"/>
</h:commandButton>
<h:commandButton id="submit2" value="Retailer 1" styleClass="button1">
<f:actionListener binding="#{loginweb.setNewUsernameAndCreateUser('Retailer1')}"/>
</h:commandButton>
<h:commandButton id="submit3" value="Wholesaler 1" styleClass="button1">
<f:actionListener binding="#{loginweb.setNewUsernameAndCreateUser('Wholesaler1')}"/>
</h:commandButton>
<br></br><h:commandButton id="submit4" value="Brewery 2" styleClass="button1">
<f:actionListener binding="#{loginweb.setNewUsernameAndCreateUser('Brewery2')}"/>
</h:commandButton>
<h:commandButton id="submit5" value="Distributor 2" styleClass="button1">
<f:actionListener binding="#{loginweb.setNewUsernameAndCreateUser('Distributor2')}"/>
</h:commandButton>
<h:commandButton id="submit6" value="Retailer 2" styleClass="button1">
<f:actionListener binding="#{loginweb.setNewUsernameAndCreateUser('Retailer2')}"/>
</h:commandButton>
<h:commandButton id="submit7" value="Wholesaler 2" styleClass="button1">
<f:actionListener binding="#{loginweb.setNewUsernameAndCreateUser('Wholesaler2')}"/>
</h:commandButton>
<br></br><h:commandButton id="submit8" value="Brewery 3" styleClass="button1">
<f:actionListener binding="#{loginweb.setNewUsernameAndCreateUser('Brewery3')}"/>
</h:commandButton>
<h:commandButton id="submit9" value="Distributor 3" styleClass="button1">
<f:actionListener binding="#{loginweb.setNewUsernameAndCreateUser('Distributor3')}"/>
</h:commandButton>
<h:commandButton id="submit10" value="Retailer 3" styleClass="button1">
<f:actionListener binding="#{loginweb.setNewUsernameAndCreateUser('Retailer3')}"/>
</h:commandButton>
<h:commandButton id="submit11" value="Wholesaler 3" styleClass="button1">
<f:actionListener binding="#{loginweb.setNewUsernameAndCreateUser('Wholesaler3')}"/>
</h:commandButton>
</div>
</h:form>
<h:form id="dialogform">
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="refresh" content="10"/>
<div id="dialog" class="block_screen" style="display: none">
<div class="loading-screen" style="margin-top: 10%;">
<div id="container">
<div class="pour"></div>
<div id="beaker">
<div class="beer-foam">
<div class="foam-1"></div>
<div class="foam-2"></div>
<div class="foam-3"></div>
<div class="foam-4"></div>
<div class="foam-5"></div>
<div class="foam-6"></div>
<div class="foam-7"></div>
</div>
<div id="liquid">
<div class="bubble bubble1"></div>
<div class="bubble bubble2"></div>
<div class="bubble bubble3"></div>
<div class="bubble bubble4"></div>
<div class="bubble bubble5"></div>
</div>
</div>
</div>
<div style="text-align: center">
<h2 style="color:#0065bd;">Please wait until the administrator has added you to a game!</h2>
</div>
</div>
<!-- <div class="modal">-->
<!-- <div class="modal-dialog">-->
<!-- <div class="modal-header">-->
<!-- <h2>Please wait until the administrator has added you to a game!</h2>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
</div>
</h:form>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
crossorigin="anonymous" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.pour')
.delay(2000)
.animate({
height: '360px'
}, 1500)
.delay(1600)
.slideUp(500);
$('#liquid')
.delay(3400)
.animate({
height: '170px'
}, 2500);
$('.beer-foam')
.delay(3400)
.animate({
bottom: '200px'
}, 2500);
});
if (('${loginweb.newUserName}' !== "" || '${loginweb.userName}' !== "") && '${loginweb.newGameID}' === "") {
document.getElementById("dialog").style.display = 'block';
document.getElementById("inputForm").style.opacity = '0.0';
} else if ('${loginweb.newGameID}' !== "") {
window.location.replace("beergame_user.xhtml");
}
</script>
</h:body>
</html>
`]1] 1谢谢
暂无答案!
目前还没有任何答案,快来回答吧!