-1

Possible Duplicate:
Javascript change div content upon a click

What I'm trying to do is have this code update the original Test

<div class="show">

with what the user has put there.

    <style type="text/css">
    /* Normal mode */
    .weight-display div.edit {display:none}
    /* Editor mode */
    .weight-edit div.show {display:none}
</style>
<div class="weight-display">
    <button onclick="toggle(this)">Edit this!</button>
    <div class="edit"><select name="Category">
<option value="Department">Department</option>
<option value="Accounts">Accounts</option><option value="Claims">HR</option><option value="Yachts UW">IT</option><option value="Marine Trade">Marketing</option></select></div>
    <div class="show">Test</div>
</div>
<script type="text/javascript">
    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';
    }
</script>

original: Original

EDIT: http://jsfiddle.net/f9mBm/

Community
  • 1
  • 1
Mark Price
  • 582
  • 1
  • 8
  • 18
  • What is the problem that you are facing ? – Apurv Feb 03 '12 at 12:20
  • Is there andy difference to your previous question? If not, please don't ask a question twice but clarify your original one. Apart form that, this current question does not contain enough information to understand your problem. – Felix Kling Feb 03 '12 at 12:20
  • When i try this it doesn't update the text http://jsfiddle.net/f9mBm/ – Mark Price Feb 03 '12 at 12:22
  • Hi Felix, I've never asked this question before. My requirements are different to the question that I linked to in my question then you posted as a possible duplicate. – Mark Price Feb 03 '12 at 12:40
  • It seems to work fine in chrome. Which browser are you using? http://jsfiddle.net/f9mBm/1/ – Markus Andersson Feb 03 '12 at 12:49
  • Hi, I'm using firefox 10.0 Maybe I've explained myself poorly sorry. http://jsfiddle.net/f9mBm/2/ Does this work for you? When I click Save it still displays the original value in the div "Show". – Mark Price Feb 03 '12 at 13:05

1 Answers1

1

Ok so if I understand you correctly you want to get the selected value from the dropdown and set that value to the div.show ?

In that case you can do something like this http://jsfiddle.net/f9mBm/3/