我想显示一个确认对话框,例如"您想继续吗?"如果是"是",我想弹出一个显示表单输出的消息,如果"否"我想留在同一页面上。
在下面所示的代码中,我正在导航到facto.html
进行分配输出,但我想展示带有其内容的弹出窗口。我该怎么做?
我的index.html
:
<!DOCTYPE html>
<html>
<head>
<title>Lift From Scratch</title>
<script type="text/javascript">
<!--
function getConfirmation(){
var retVal = confirm("Do you want to continue ?");
if( retVal == true ){
<!--document.write("continue")-->
<!--window.location.href = '/facto.html';-->
return true;
}
else{
alert("Don't continue")
<!--window.location.href = 'index.html';-->
return false;
}
}
//-->
</script>
</head>
<body>
<h1>Finding Factorial</h1>
<div id="main" class="lift:surround?with=default&at=content">
<form method="post">
<table>
<tr><td> Enter a Number:</td> <td><input name="num" type="number"></td></tr>
<tr><td><input type="submit" value="Submit" onclick="getConfirmation();" formaction="facto"></td>
<td><input type="reset" value="Reset"></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
facto.html:
<div data-lift="factorial">
<p>Factorial is: <span name="paramname"></span></p>
</div>
尝试这样的东西:
function validateMyForm()
{
if( confirm('Are you sure?') )
return true; // will submit the form
else
return false; // do not submit the form
}
<form name="myForm" onsubmit="return validateMyForm();">
<input type="submit" value="Submit" />
</form>
老实说,您可能会想回到JavaScript。您可以使用Lift的SHtml.makeFormsAjax
助手将表单变为AJAX表单,然后可以使用SHtml.ajaxSubmit
绑定提交按钮。您传递给ajaxSubmit
的回调应返回JsCmd
。JsCmd
可以触发弹出窗口的显示。您甚至可以使用SHtml.idMemoize
渲染弹出窗口的内容。
如果您对升降机组进行更详细的详细描述,您可能会发现人们愿意帮助您解决一些更具体的方面。