Note that there are some explanatory texts on larger screens.

plurals
  1. POrefresh the page without redirecting
    primarykey
    data
    text
    <p>I have a search form like this in a file form.php. It works great, the problem I am facing is that I use class/methods(functions). For example I have this method that calls logo and manu bar.</p> <pre><code> //$this-&gt;output is just a method that echos, that's all it does function header() { $this-&gt;output('&lt;DIV CLASS="header"&gt;'); $this-&gt;logo(); include('form.php'); $this-&gt;links(); $this-&gt;header_clear(); $this-&gt;output('&lt;/DIV&gt;'); } </code></pre> <p>Like the above, the form shows perfectly, but when I choose a category it takes me to form.php, and it ruins everything. (form.php is just a form)</p> <p>I know the problem is here</p> <pre><code> onChange="javascript:this.form.action='form.php'; this.form.submit() </code></pre> <p>Without javascript I couldn't get the category values, the page is not refreshing, so $_POST['cat'] is empty.</p> <p>What is a better way to refresh the page without taking me to different one?</p> <p>I know probably this all confusing, just bear with me.</p> <pre><code> &lt;form enctype="multipart/form-data" name="form" id="form" action="form.php" method="get"&gt; &lt;SELECT name="cat" onChange="javascript:this.form.action='form.php'; this.form.submit()"&gt; &lt;option value="" &gt;Categories&lt;/option&gt; &lt;?php $z = "0" ; //Select categories form database $category =db_select_categories($z); if(is_array($category)) { foreach($category as $rowc) { $id_cat = htmlentities($rowc['id_cat'], ENT_QUOTES); $cat_name = htmlentities($rowc['cat_name'], ENT_QUOTES, 'utf-8'); $cat_name = stripslashes($cat_name); echo "&lt;option style=\"background-color:#FFCC99\" disabled&gt;".$cat_name." &lt;/option&gt;"; $categories = db_select_categories($id_cat); if(is_array($categories)) { foreach($categories as $row) { $id = htmlentities($row['id_cat'], ENT_QUOTES); $name = htmlentities($row['cat_name'], ENT_QUOTES, 'utf-8'); $name = stripslashes($name); if ( $cat == $id ) { echo "&lt;option value='".$id."'selected&gt; ".$name."&lt;/option&gt;"; } else { echo "&lt;option value=".$id."&gt; ".$name."&lt;/option&gt;"; } } } } } echo "&lt;/SELECT&gt;"; ?&gt; &lt;div&gt; &lt;?php if(!empty($cat)) { //Outputs a populated select option depending on category display_search_options($cat); } ?&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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