<?
session_start();
include("connection.php");
if($_POST['continue'])
{
$x=$_POST['rules'];
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" href="jquery-ui-1.7.2.custom.css" rel="stylesheet" />
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript" src="ui/ui.core.js"></script>
<script type="text/javascript" src="ui/ui.draggable.js"></script>
<script type="text/javascript" src="ui/ui.resizable.js"></script>
<script type="text/javascript" src="ui/ui.dialog.js"></script>
<script type="text/javascript" src="external/bgiframe/jquery.bgiframe.js"></script>
<script type="text/javascript">
function haha(form)
{
if(form.rules.value=='')
{
printToPage('output','Please enter the rules.','text')
hello();
return false;
}
else
{
myRedirect();
return false;
}
}
$(function()
{
$("#dialog").dialog({
autoOpen: false,
bgiframe: true,
resizable: false,
draggable: false,
height:10,
width:340,
modal: true,
overlay:
{
backgroundColor: '#000',
opacity: 0.5
},
buttons:
{
'No': function()
{
window.location = "so-rules.php";
return true;
},
'Yes': function()
{
window.location = "so-rules.php";
return true;
}
}
});
});
function myRedirect()
{
$("#dialog").dialog('open');
return true;
}
$(function()
{
$("#dialog2").dialog
({
autoOpen: false,
bgiframe: true,
modal: true,
resizable: false,
draggable: false,
height:160,
width:260,
buttons:
{
Ok: function()
{
$(this).dialog('close');
}
}
});
});
function hello()
{
$("#dialog2").dialog('open');
}
function getElem(id)
{
return document.all ? document.all(id) :
document.getElementById ? document.getElementById(id) :
document.layers ? document.layers[id] :
null;
}
function printToPage(id,content,classname)
{
var el = getElem(id);
if (!el) return;
if (el.style)
{
el.innerHTML = content;
if (classname) el.className = classname;
}
else if (el.document)
{
var SPANstr = (classname) ? '<span class="' + classname + '">' : '<span>';
el.document.write('haha');
el.document.close();
}
}
</script>
</head>
<body>
<td height="" bgcolor="#fafb91"><form onsubmit='return haha(form)' id="form" name="form" method="post" action="<? echo $PHP_SELF; ?>">
<p class="style16">
<div align="left">
<p><span class="style5">Rules:</span>
</p>
<p>
<textarea name="rules" rows="7" cols="49"></textarea>
<br />
<? echo "X: ".$_SESSION['x']; ?>
</p>
<div id="dialog" title="Attention">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Is the judge/speaker/facilitator from UST?</p>
</div>
<div id="dialog2" title="Attention">
<p>
<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 0 50px 0;"></span>
Please enter the rules.
</p>
</div>
<p><input type="submit" name="continue" id="continue" value="Continue">
<span id="output"></span>
</body>
</html>
当 textarea 不为 null 时,应该提交表单($PHP_SELF),这样我才能得到 textarea 的值。但在提交之前,会出现一个对话框。当用户单击是时,他将被重定向到不同的页面。我的问题是我不知道将 return 'true' 放在哪里,以便提交页面以便我获取 textarea 的值。我把返回“假”放在这里:
if(form.rules.value=='')
{
printToPage('output','Please enter the rules.','text')
hello();
return false;
}
当 textarea 为空时,表单将不会提交,并会出现一个不同的对话框。我应该把返回“true”放在哪里,以便只有当用户在 textarea 中输入内容并单击“是”后才会提交页面。
我已经发布了我尝试输入返回“true”但没有成功的代码。