Note that there are some explanatory texts on larger screens.

plurals
  1. POchange p tag class with multiple drop downs
    primarykey
    data
    text
    <p>can someone tell me how to have multiple dropdown, consisting of size, weight, font clolor, and font family. Once the user selects one from each drop down, the click submit and the p or div element is changed? i have code for one, but not sure how to change multiple? i also need to changing to the button on click and the display appears in a p tag instead of the actual button.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;title&gt;JS Change Class&lt;/title&gt; &lt;style type="text/css" media="screen"&gt; .red { border: 1px solid red; } .blue { border: 1px solid blue; } .green { border: 1px solid green; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;select id="colors"&gt; &lt;option value="red"&gt;Red&lt;/option&gt; &lt;option value="blue"&gt;Blue&lt;/option&gt; &lt;option value="green"&gt;Green&lt;/option&gt; &lt;/select&gt; &lt;input type="button" class="red" value="This is a button" id="button" /&gt; &lt;script type="text/javascript" charset="utf-8"&gt; var colors = document.getElementById('colors'); var button = document.getElementById('button'); addEvent(colors, 'change', function() { button.className = colors.value; }); // Based on the lessons from Nettuts function addEvent(obj, evt, fn) { evt = evt.replace('on', ''); if( obj.attachEvent ) obj.attachEvent('on' + evt, fn); else obj.addEventListener(evt, fn, false); } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>**update: i want to add, three more drop downs, size x3 options, font-family x3 options and font weight x3 options. the user should be able to selct from each, then click the submit button and it will display in a p tag.</p>
    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