<?
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>
when the textarea is not null, the form should be submitted ($PHP_SELF) so i can get the value of the textarea. but before it is submitted there would be a dialog box that would appear. when the user clicks yes, he will be redirected to a different page. my problem is i don't know where to put the return true so that the page will be submitted in order for me to get the value of the textarea. i put the return false here:
if(form.rules.value==''){
printToPage('output','Please enter the rules.','text')
hello();
return false;
}
when the textarea is null, the form will not submit and a different dialog box will appear.
where should i put the return true so that the page will only be submitted when the user input something in the textarea and after he clicks yes.
i have also included in the code where i have tried putting the return true but all failed. please help me. i've been trying to fix this for 3 days. :(