Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Thanks @Salman for your suggestions as they lead me in the right direction and I managed to solve the problem. I managed to pass multiple parameters with the ajax .load() call by passing them as get parameters. The results of the ajaxAction could then be formatted in the ajax.ajax.phtml view and were consecutively shown within the #results div that resides in the index.phtml where the select boxes are.</p> <h3>controller/index.phtml</h3> <pre><code>&lt;div id="results" style="display:block;"&gt;Select all three values&lt;/div&gt; </code></pre> <h3>IndexController init and ajaxAction</h3> <pre><code>public function init() { $ajaxContext = $this-&gt;_helper-&gt;getHelper('AjaxContext'); $ajaxContext-&gt;addActionContext('ajax', 'html')-&gt;initContext('html'); } public function ajaxAction() { $select1 = $this-&gt;_request-&gt;getQuery('select1'); $select2 = $this-&gt;_request-&gt;getQuery('select2'); $select3 = $this-&gt;_request-&gt;getQuery('select3'); $form = new Application_Form(); // Database operations and logic $this-&gt;view-&gt;form = $form; $this-&gt;view-&gt;array = $somearray; } } </code></pre> <h3>jquery script in index.phtml</h3> <pre><code>$(document).ready(function(){ $('.selector').change(function() { var select1 = $('#select1').val(); var select2 = $('#select2').val(); var select3 = $('#select3').val(); if ( select1 &amp;&amp; select2 &amp;&amp; select3) { $('#results').show(); $('#results').load('/controller/ajax?select1=' + select1 + '&amp;select2=' + select2 + '&amp;select3=' + select3); } }); }); </code></pre> <h3>controller/ajax.ajax.phtml</h3> <pre><code>&lt;?php if ( $this-&gt;array ) : ?&gt; &lt;?php echo( $this-&gt;form ); ?&gt; &lt;?php else: ?&gt; Nothing found for selected values &lt;?php endif ?&gt; </code></pre>
 

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