Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript to update div with user input
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/5862489/javascript-change-div-content-upon-a-click">Javascript change div content upon a click</a> </p> </blockquote> <p>What I'm trying to do is have this code update the original Test </p> <pre><code>&lt;div class="show"&gt; </code></pre> <p>with what the user has put there.</p> <pre><code> &lt;style type="text/css"&gt; /* Normal mode */ .weight-display div.edit {display:none} /* Editor mode */ .weight-edit div.show {display:none} &lt;/style&gt; &lt;div class="weight-display"&gt; &lt;button onclick="toggle(this)"&gt;Edit this!&lt;/button&gt; &lt;div class="edit"&gt;&lt;select name="Category"&gt; &lt;option value="Department"&gt;Department&lt;/option&gt; &lt;option value="Accounts"&gt;Accounts&lt;/option&gt;&lt;option value="Claims"&gt;HR&lt;/option&gt;&lt;option value="Yachts UW"&gt;IT&lt;/option&gt;&lt;option value="Marine Trade"&gt;Marketing&lt;/option&gt;&lt;/select&gt;&lt;/div&gt; &lt;div class="show"&gt;Test&lt;/div&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; function toggle(button) { // Change the button caption button.innerHTML = button.innerHTML=='Edit this!' ? 'Save' : 'Edit this!'; // Change the parent div's CSS class var div = button.parentNode; div.className = div.className=='weight-display' ? 'weight-edit' : 'weight-display'; } &lt;/script&gt; </code></pre> <p>original: <a href="https://stackoverflow.com/questions/5862489/javascript-change-div-content-upon-a-click">Original</a></p> <p>EDIT: <a href="http://jsfiddle.net/f9mBm/" rel="nofollow noreferrer">http://jsfiddle.net/f9mBm/</a></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