Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript, jQuery, PHP issue.
    text
    copied!<pre><code>&lt;? session_start(); include("connection.php"); if($_POST['continue']) { $x=$_POST['rules']; } ?&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;link type="text/css" href="jquery-ui-1.7.2.custom.css" rel="stylesheet" /&gt; &lt;script src="SpryAssets/SpryMenuBar.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="jquery-1.3.2.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="ui/ui.core.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="ui/ui.draggable.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="ui/ui.resizable.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="ui/ui.dialog.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="external/bgiframe/jquery.bgiframe.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; 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) ? '&lt;span class="' + classname + '"&gt;' : '&lt;span&gt;'; el.document.write('haha'); el.document.close(); } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;td height="" bgcolor="#fafb91"&gt;&lt;form onsubmit='return haha(form)' id="form" name="form" method="post" action="&lt;? echo $PHP_SELF; ?&gt;"&gt; &lt;p class="style16"&gt; &lt;div align="left"&gt; &lt;p&gt;&lt;span class="style5"&gt;Rules:&lt;/span&gt; &lt;/p&gt; &lt;p&gt; &lt;textarea name="rules" rows="7" cols="49"&gt;&lt;/textarea&gt; &lt;br /&gt; &lt;? echo "X: ".$_SESSION['x']; ?&gt; &lt;/p&gt; &lt;div id="dialog" title="Attention"&gt; &lt;p&gt;&lt;span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"&gt;&lt;/span&gt;Is the judge/speaker/facilitator from UST?&lt;/p&gt; &lt;/div&gt; &lt;div id="dialog2" title="Attention"&gt; &lt;p&gt; &lt;span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 0 50px 0;"&gt;&lt;/span&gt; Please enter the rules. &lt;/p&gt; &lt;/div&gt; &lt;p&gt;&lt;input type="submit" name="continue" id="continue" value="Continue"&gt; &lt;span id="output"&gt;&lt;/span&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>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, a dialog box 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:</p> <pre><code>if(form.rules.value=='') { printToPage('output','Please enter the rules.','text') hello(); return false; } </code></pre> <p>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 inputs something in the textarea and after he clicks 'yes'.</p> <p>I have posted the code where I tried putting in the return 'true' without success.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload