Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting a random image depending on ajax reply on a select box?
    text
    copied!<p>I currently have a HTML select box like below.</p> <pre><code>&lt;select name="item_1"&gt; &lt;option value="0"&gt;Choose one...&lt;/option&gt; &lt;option value="1"&gt;Value (1)&lt;/option&gt; &lt;option value="2"&gt;Value (2)&lt;/option&gt; &lt;option value="3"&gt;Value (3)&lt;/option&gt; &lt;/select&gt; </code></pre> <p>I have to do the following. Either way works, but I want to learn both, if possible.</p> <p><strong>A.</strong> </p> <ol> <li>Imagine there is 3x different select boxes called item_1, item_2 and item_3.</li> <li>Imagine a div (or a table) on any place of current document.</li> <li>Whenever the value on select box changes, the div should contain a link to picture with option value.</li> </ol> <p>For example, if "Value (2)" gets selected in "item_1" selectbox, then it should print 2.jpg on the div. If there are selected values in other selectboxes, it should also be printing their images.</p> <p>Example: item_1 -> Value (2) -- item_2 -> Value (3) -- Output -> &lt; img src="2.jpg">, &lt; img src=3.jpg"></p> <p>How can I do this?</p> <p><strong>B.</strong> </p> <p>The same question as above, except; instead of directly printing the picture link depending on selectbox value, we will do a AJAX request to our PHP file. PHP will return the additional information about the selected value in selectbox. (e.g if you selected "value 2", it may get it's price, stock_count or picture_path or w/e from database.)</p> <p>Depending on the returned values, we will get image_path value from database so instead of printing 2.jpg, it may print my_cute_dog.jpg.</p> <p>How can I do this? I'll be glad if you can guide me.</p> <p>Thank you, Anil</p> <p>Ps. No need to code PHP. Just give me the PHP file name, parameters and method. (POST prefered). I just need some basic jQuery/JS help, or guidance.</p> <p>Ps. 2 You can name divs however you want.</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