Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate div class based on select option
    primarykey
    data
    text
    <p>This is borrowed from another question I made on the site, but would have got really messy.</p> <p>So using some of the code from one of the repliers, how do I get this code to work... or have I got it completely wrong.</p> <p>Select Options are:</p> <pre><code>&lt;select style="width: 220px; display: none;" id="speedB" name="category"&gt; &lt;option value=""&lt;?if ($category == ""){?&gt; selected="selected"&lt;?}?&gt;&gt;Please Select&lt;/option&gt; &lt;option value="1"&lt;?if ($category == "1"){?&gt; selected="selected"&lt;?}?&gt;&gt;Pest Inspectors&lt;/option&gt; &lt;option value="3"&lt;?if ($category == "3"){?&gt; selected="selected"&lt;?}?&gt;&gt;Building Inspectors&lt;/option&gt; &lt;option value="2"&lt;?if ($category == "2"){?&gt; selected="selected"&lt;?}?&gt;&gt;Removalists&lt;/option&gt; &lt;option value="5"&lt;?if ($category == "5"){?&gt; selected="selected"&lt;?}?&gt;&gt;Conveyancing&lt;/option&gt; &lt;option value="4"&lt;?if ($category == "4"){?&gt; selected="selected"&lt;?}?&gt;&gt;Pool Inspectors&lt;/option&gt; &lt;/select&gt; </code></pre> <p>JavaScript:</p> <pre><code>$('#speedB').change(function() { var myTypes = { '': '.nothing', '1': '.pest', '2': '.build', '3': '.removals', '4': '.legal', '5': '.pool' } var selectedType = myTypes[$(this).val()]; $('#topright').html('&lt;div class="'+selectedType+'"/&gt;&lt;/div&gt;'); }); </code></pre> <p>HTML:</p> <pre><code>&lt;div id="topright"&gt;&lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>#topright { height: 70px; position: absolute; right: 0; top: 0; width: 70px; } .pest { background: url("images/pestcorner.png") no-repeat scroll 0 0 transparent; } .build { background: url("images/buildcorner.png") no-repeat scroll 0 0 transparent; } .removals { background: url("images/removalscorner.png") no-repeat scroll 0 0 transparent; } .legal { background: url("images/legalcorner.png") no-repeat scroll 0 0 transparent; } .pool { background: url("images/poolcorner.png") no-repeat scroll 0 0 transparent; } </code></pre> <p>Essentially, I want user to select from select box, and that invokes display of the css class.</p> <p>I think I have screwed the js up.</p>
    singulars
    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.
 

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