Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML Drop Down List to Select Radio Button
    primarykey
    data
    text
    <p>I have a problem that I'm hoping to get some direction in solving - I'm building an eCommerce site that includes a page displaying product options. One of the options is selecting the product's color by selecting a swatch. Once the swatch is selected, using JQuery, a red border goes on the selected swatch. At the same time, the same color option is selected in an HTML drop down list/menu, which works perfectly. The problem comes when I want the reverse done: when a user selects the option from the drop down list, I need the corresponding swatch to have a border on it. Not my choice, but that's the way the customer wants it.</p> <p>I've looked everywhere that I can but none of the solutions I've found seem to work. Any guidance on this one?</p> <p>The JQuery:</p> <pre><code>jQuery(document).ready(function($) { $('.checkboxes input').each(function(index, value) { $(this).parent().prepend('&lt;div class="color" color="' + $(this).attr('color') + '" style="background: url(\'../../../../images/textiles/' + $(this).attr('color') + '.jpg\')"&gt; &lt;/div'); }); $('.color').click(function(e){ //alert($(this).attr('color')); $('.color').removeClass('selected'); $(this).addClass('selected'); $('input[color=' + $(this).attr('color') + ']').click(); }); }); </code></pre> <p>The html radio buttons and drop down list:</p> <pre><code>&lt;div class="checkboxes"&gt; &lt;input type="radio" onclick="javascript:void goToOption(document.gobag.color_list,'Multicam')" color="multicam" name="color" value="Multicam" style="visibility: hidden"/&gt; &lt;input type="radio" onclick="javascript:void goToOption(document.gobag.color_list,'Marpat')" color="marpat" name="color" value="Marpat" style="visibility: hidden"/&gt; &lt;input type="radio" onclick="javascript:void goToOption(document.gobag.color_list,'UC')" color="UC" name="color" value="UC"style="visibility: hidden"/&gt; &lt;input type="radio" onclick="javascript:void goToOption(document.gobag.color_list,'Coyote')" color="coyote" name="color" value="Coyote" style="visibility: hidden"/&gt; &lt;input type="radio" onclick="javascript:void goToOption(document.gobag.color_list,'Khaki')" color="khaki" name="color" value="Khaki" style="visibility: hidden"/&gt; &lt;input type="radio" onclick="javascript:void goToOption(document.gobag.color_list,'Foliage')" color="foliage" name="color" value="Foliage" style="visibility: hidden"/&gt; &lt;input type="radio" onclick="javascript:void goToOption(document.gobag.color_list,'Black')" color="black" name="color" value="Black" style="visibility: hidden" /&gt; &lt;/div&gt;&lt;/span&gt;&lt;br /&gt; &lt;select name="color_list" onchange=""&gt; &lt;option selected="selected"&gt;Select a Color&lt;/option&gt; &lt;option name="Black" &gt;Black&lt;/option&gt; &lt;option name="Foliage" &gt;Foliage&lt;/option&gt; &lt;option name="Khaki" &gt;Khaki&lt;/option&gt; &lt;option name="Coyote" &gt;Coyote&lt;/option&gt; &lt;option name="UC" &gt;UC&lt;/option&gt; &lt;option name="Marpat" &gt;Marpat&lt;/option&gt; &lt;option name="Multicam" &gt;Multicam&lt;/option&gt; &lt;/select&gt;&lt;br /&gt;&lt;br /&gt; </code></pre>
    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