<?
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>
Когда текстовая область не равна нулю, форма должна быть отправлена ($ PHP_SELF), чтобы я мог получить значение текстовой области. Но перед отправкой появится диалоговое окно. Когда пользователь нажимает да, он будет перенаправлен на другую страницу. Моя проблема в том, что я не знаю, где поставить возвращаемое значение «true», чтобы страница была отправлена, чтобы я мог получить значение текстовой области. Я положил возвращение «ложь» здесь:
if(form.rules.value=='')
{
printToPage('output','Please enter the rules.','text')
hello();
return false;
}
Когда текстовое поле равно нулю, форма не будет отправлена, и появится другое диалоговое окно. Куда следует поместить возвращаемое значение «истина», чтобы страница передавалась только тогда, когда пользователь вводит что-то в текстовое поле и после нажатия «да».
Я отправил код, в котором я пытался вставить возвращаемое значение «true», но безуспешно.