getElementById not returning current text from text area in javascript functionHow do I remove a property from a JavaScript object?Set a default parameter value for a JavaScript functionGet the current URL with JavaScript?How do I get the current date in JavaScript?Get selected text from a drop-down list (select box) using jQueryIs there a standard function to check for null, undefined, or blank variables in JavaScript?How do I remove a particular element from an array in JavaScript?Get the current year in JavaScriptHow do I return the response from an asynchronous call?Cannot display HTML string

Is there any proof that high saturation and contrast makes a picture more appealing in social media?

Is "Busen" just the area between the breasts?

Too early in the morning to have SODA?

How would modern naval warfare have to have developed differently for battleships to still be relevant in the 21st century?

UK - Working without a contract. I resign and guy wants to sue me

Why is oilcloth made with linseed oil?

How did Gollum enter Moria?

How to make clear to people I don't want to answer their "Where are you from?" question?

What is the origin of Scooby-Doo's name?

Where's this swanky house and vineyard near a mountain?

How many people are necessary to maintain modern civilisation?

Intuition for the role of diffeomorphisms

Trainee keeps passing deadlines for independent learning

Is declining an undergraduate award which causes me discomfort appropriate?

Why tighten down in a criss-cross pattern?

Encounter design and XP thresholds

`-` in tar xzf -

How to maintain a closed environment for one person for a long period of time

How does DC work with natural 20?

What can I do with a research project that is my university’s intellectual property?

Constitutionality of U.S. Democratic Presidential Candidate's Supreme Court Suggestion

What happened to Steve's Shield in Iron Man 2?

Excluding a rectangular region from an image in FITS

Putting a plot inside a tab



getElementById not returning current text from text area in javascript function


How do I remove a property from a JavaScript object?Set a default parameter value for a JavaScript functionGet the current URL with JavaScript?How do I get the current date in JavaScript?Get selected text from a drop-down list (select box) using jQueryIs there a standard function to check for null, undefined, or blank variables in JavaScript?How do I remove a particular element from an array in JavaScript?Get the current year in JavaScriptHow do I return the response from an asynchronous call?Cannot display HTML string






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















My function document.getelementbyid is not returning the current value of the textarea from HTML page



HTML:



<div class="modal-content">
<h4 class="modal-title">PersonName</h4>
<div id = 'person_name' class="modal-body">
<p><%=person['person_name']%></p>
</div>
<h4 class="modal-title">Person Description</h4>
<textarea id="person_descr" style="overflow: scroll; height:
100px;"></textarea>
<button name="button" type="button" class="save"
class="btn btn-info"
onClick="updateDescription('<%=person['person_name']%>')">
save description </button>
</div>


JavaScript:



function updateDescription(person_name) 
var person_name = person_name
var person_descr = document.getElementById("person_descr").value;
alert(person_name)
alert(person_descr)



In text-area I can edit the existing value and Save that modified value into DB.



When clicked on 'save description' button it is returning 1st element which is passing to text-area but need to get current value of text-area










share|improve this question
























  • You've more than one textarea element, right? And they all have the same id ..?

    – Teemu
    Mar 25 at 7:04











  • i fiddled it. no problem here. what is your output ? jsfiddle.net/qdmc4s3v

    – Doruk
    Mar 25 at 7:10











  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. See: How to create a minimal reproducible example.

    – LGSon
    Mar 25 at 7:20


















-1















My function document.getelementbyid is not returning the current value of the textarea from HTML page



HTML:



<div class="modal-content">
<h4 class="modal-title">PersonName</h4>
<div id = 'person_name' class="modal-body">
<p><%=person['person_name']%></p>
</div>
<h4 class="modal-title">Person Description</h4>
<textarea id="person_descr" style="overflow: scroll; height:
100px;"></textarea>
<button name="button" type="button" class="save"
class="btn btn-info"
onClick="updateDescription('<%=person['person_name']%>')">
save description </button>
</div>


JavaScript:



function updateDescription(person_name) 
var person_name = person_name
var person_descr = document.getElementById("person_descr").value;
alert(person_name)
alert(person_descr)



In text-area I can edit the existing value and Save that modified value into DB.



When clicked on 'save description' button it is returning 1st element which is passing to text-area but need to get current value of text-area










share|improve this question
























  • You've more than one textarea element, right? And they all have the same id ..?

    – Teemu
    Mar 25 at 7:04











  • i fiddled it. no problem here. what is your output ? jsfiddle.net/qdmc4s3v

    – Doruk
    Mar 25 at 7:10











  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. See: How to create a minimal reproducible example.

    – LGSon
    Mar 25 at 7:20














-1












-1








-1








My function document.getelementbyid is not returning the current value of the textarea from HTML page



HTML:



<div class="modal-content">
<h4 class="modal-title">PersonName</h4>
<div id = 'person_name' class="modal-body">
<p><%=person['person_name']%></p>
</div>
<h4 class="modal-title">Person Description</h4>
<textarea id="person_descr" style="overflow: scroll; height:
100px;"></textarea>
<button name="button" type="button" class="save"
class="btn btn-info"
onClick="updateDescription('<%=person['person_name']%>')">
save description </button>
</div>


JavaScript:



function updateDescription(person_name) 
var person_name = person_name
var person_descr = document.getElementById("person_descr").value;
alert(person_name)
alert(person_descr)



In text-area I can edit the existing value and Save that modified value into DB.



When clicked on 'save description' button it is returning 1st element which is passing to text-area but need to get current value of text-area










share|improve this question
















My function document.getelementbyid is not returning the current value of the textarea from HTML page



HTML:



<div class="modal-content">
<h4 class="modal-title">PersonName</h4>
<div id = 'person_name' class="modal-body">
<p><%=person['person_name']%></p>
</div>
<h4 class="modal-title">Person Description</h4>
<textarea id="person_descr" style="overflow: scroll; height:
100px;"></textarea>
<button name="button" type="button" class="save"
class="btn btn-info"
onClick="updateDescription('<%=person['person_name']%>')">
save description </button>
</div>


JavaScript:



function updateDescription(person_name) 
var person_name = person_name
var person_descr = document.getElementById("person_descr").value;
alert(person_name)
alert(person_descr)



In text-area I can edit the existing value and Save that modified value into DB.



When clicked on 'save description' button it is returning 1st element which is passing to text-area but need to get current value of text-area







javascript html html5






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 15 at 14:08









TylerH

16.3k105671




16.3k105671










asked Mar 25 at 7:01









SrkSrk

267




267












  • You've more than one textarea element, right? And they all have the same id ..?

    – Teemu
    Mar 25 at 7:04











  • i fiddled it. no problem here. what is your output ? jsfiddle.net/qdmc4s3v

    – Doruk
    Mar 25 at 7:10











  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. See: How to create a minimal reproducible example.

    – LGSon
    Mar 25 at 7:20


















  • You've more than one textarea element, right? And they all have the same id ..?

    – Teemu
    Mar 25 at 7:04











  • i fiddled it. no problem here. what is your output ? jsfiddle.net/qdmc4s3v

    – Doruk
    Mar 25 at 7:10











  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. See: How to create a minimal reproducible example.

    – LGSon
    Mar 25 at 7:20

















You've more than one textarea element, right? And they all have the same id ..?

– Teemu
Mar 25 at 7:04





You've more than one textarea element, right? And they all have the same id ..?

– Teemu
Mar 25 at 7:04













i fiddled it. no problem here. what is your output ? jsfiddle.net/qdmc4s3v

– Doruk
Mar 25 at 7:10





i fiddled it. no problem here. what is your output ? jsfiddle.net/qdmc4s3v

– Doruk
Mar 25 at 7:10













Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. See: How to create a minimal reproducible example.

– LGSon
Mar 25 at 7:20






Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. See: How to create a minimal reproducible example.

– LGSon
Mar 25 at 7:20













5 Answers
5






active

oldest

votes


















1














Escape the ' inside your onClick function call.



onClick="updateDescription('<%=person['person_name']%>')"





share|improve this answer






























    1














    Your quotations inside your onclick aren't being escaped:



    <button name="button" type="button" class="save" class="btn btn-info" onClick="updateDescription('<%=person['person_name']%>')">save description</button>





    share|improve this answer






























      1














      When document load your textarea still is empty it show empty at alert. You need set value by person_descr.value = person_name;






      function updateDescription(person_name)

      var person_name= person_name

      var person_descr= document.getElementById("person_descr");
      alert(person_name)
      alert(person_descr.value);
      person_descr.value = person_name;
      alert(person_descr.value)

      <div class="modal-content">
      <h4 class="modal-title">PersonName</h4>
      <div id = 'person_name' class="modal-body">
      <p>aaa</p>
      </div>
      <h4 class="modal-title">Person Description</h4>
      <textarea id="person_descr" style="overflow: scroll; height:
      100px;"></textarea>
      <button name="button" type="button" class="save"
      class="btn btn-info"
      onClick="updateDescription('aaa')">
      save description </button>
      </div>








      share|improve this answer






























        0














        to get a html text area value, you can use the value property:



        document.getElementById("id").value


        also you have to escape your html quotes:



        <button name="button" type="button" class="save" 
        class="btn btn-info"
        onClick="updateDescription('<%=person['person_name']%>')">
        save description </button>





        share|improve this answer






























          0














          Avoid the limitations and awkward syntax of onevent attributes -- use onevent properties or event listeners instead. The following demo uses an onevent property.



          BTW the button is invalid it has two class attributes:



          <button name="button" type="button" class="save"
          class="btn btn-info"

          onClick="updateDescription('<%=person['person_name']%>')">
          save description </button>



          Demo






          document.querySelector('.btn').onclick = updateDesc;

          function updateDesc(e)
          var personName = document.getElementById("personName");
          var personDesc = document.getElementById("personDesc");
          console.log(personName.textContent);
          console.log(personDesc.value);

          * 
          margin: 0;
          padding: 0

          <div class="modal-content">
          <h4 class="modal-title">Person Name</h4>
          <div id='personName' class="modal-body">
          <p>
          John Doe
          </p>
          </div>
          <h4 class="modal-title">Person Description</h4>
          <textarea id="personDesc" style="overflow: scroll; height: 100px;"></textarea><br>
          <button name="button" type="button" class="btn btn-info save">Save Description</button>
          </div>








          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55332649%2fgetelementbyid-not-returning-current-text-from-text-area-in-javascript-function%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            5 Answers
            5






            active

            oldest

            votes








            5 Answers
            5






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Escape the ' inside your onClick function call.



            onClick="updateDescription('<%=person['person_name']%>')"





            share|improve this answer



























              1














              Escape the ' inside your onClick function call.



              onClick="updateDescription('<%=person['person_name']%>')"





              share|improve this answer

























                1












                1








                1







                Escape the ' inside your onClick function call.



                onClick="updateDescription('<%=person['person_name']%>')"





                share|improve this answer













                Escape the ' inside your onClick function call.



                onClick="updateDescription('<%=person['person_name']%>')"






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 7:10









                Prithviraj SahuPrithviraj Sahu

                2065




                2065























                    1














                    Your quotations inside your onclick aren't being escaped:



                    <button name="button" type="button" class="save" class="btn btn-info" onClick="updateDescription('<%=person['person_name']%>')">save description</button>





                    share|improve this answer



























                      1














                      Your quotations inside your onclick aren't being escaped:



                      <button name="button" type="button" class="save" class="btn btn-info" onClick="updateDescription('<%=person['person_name']%>')">save description</button>





                      share|improve this answer

























                        1












                        1








                        1







                        Your quotations inside your onclick aren't being escaped:



                        <button name="button" type="button" class="save" class="btn btn-info" onClick="updateDescription('<%=person['person_name']%>')">save description</button>





                        share|improve this answer













                        Your quotations inside your onclick aren't being escaped:



                        <button name="button" type="button" class="save" class="btn btn-info" onClick="updateDescription('<%=person['person_name']%>')">save description</button>






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Mar 25 at 7:15









                        Jack BashfordJack Bashford

                        26k62451




                        26k62451





















                            1














                            When document load your textarea still is empty it show empty at alert. You need set value by person_descr.value = person_name;






                            function updateDescription(person_name)

                            var person_name= person_name

                            var person_descr= document.getElementById("person_descr");
                            alert(person_name)
                            alert(person_descr.value);
                            person_descr.value = person_name;
                            alert(person_descr.value)

                            <div class="modal-content">
                            <h4 class="modal-title">PersonName</h4>
                            <div id = 'person_name' class="modal-body">
                            <p>aaa</p>
                            </div>
                            <h4 class="modal-title">Person Description</h4>
                            <textarea id="person_descr" style="overflow: scroll; height:
                            100px;"></textarea>
                            <button name="button" type="button" class="save"
                            class="btn btn-info"
                            onClick="updateDescription('aaa')">
                            save description </button>
                            </div>








                            share|improve this answer



























                              1














                              When document load your textarea still is empty it show empty at alert. You need set value by person_descr.value = person_name;






                              function updateDescription(person_name)

                              var person_name= person_name

                              var person_descr= document.getElementById("person_descr");
                              alert(person_name)
                              alert(person_descr.value);
                              person_descr.value = person_name;
                              alert(person_descr.value)

                              <div class="modal-content">
                              <h4 class="modal-title">PersonName</h4>
                              <div id = 'person_name' class="modal-body">
                              <p>aaa</p>
                              </div>
                              <h4 class="modal-title">Person Description</h4>
                              <textarea id="person_descr" style="overflow: scroll; height:
                              100px;"></textarea>
                              <button name="button" type="button" class="save"
                              class="btn btn-info"
                              onClick="updateDescription('aaa')">
                              save description </button>
                              </div>








                              share|improve this answer

























                                1












                                1








                                1







                                When document load your textarea still is empty it show empty at alert. You need set value by person_descr.value = person_name;






                                function updateDescription(person_name)

                                var person_name= person_name

                                var person_descr= document.getElementById("person_descr");
                                alert(person_name)
                                alert(person_descr.value);
                                person_descr.value = person_name;
                                alert(person_descr.value)

                                <div class="modal-content">
                                <h4 class="modal-title">PersonName</h4>
                                <div id = 'person_name' class="modal-body">
                                <p>aaa</p>
                                </div>
                                <h4 class="modal-title">Person Description</h4>
                                <textarea id="person_descr" style="overflow: scroll; height:
                                100px;"></textarea>
                                <button name="button" type="button" class="save"
                                class="btn btn-info"
                                onClick="updateDescription('aaa')">
                                save description </button>
                                </div>








                                share|improve this answer













                                When document load your textarea still is empty it show empty at alert. You need set value by person_descr.value = person_name;






                                function updateDescription(person_name)

                                var person_name= person_name

                                var person_descr= document.getElementById("person_descr");
                                alert(person_name)
                                alert(person_descr.value);
                                person_descr.value = person_name;
                                alert(person_descr.value)

                                <div class="modal-content">
                                <h4 class="modal-title">PersonName</h4>
                                <div id = 'person_name' class="modal-body">
                                <p>aaa</p>
                                </div>
                                <h4 class="modal-title">Person Description</h4>
                                <textarea id="person_descr" style="overflow: scroll; height:
                                100px;"></textarea>
                                <button name="button" type="button" class="save"
                                class="btn btn-info"
                                onClick="updateDescription('aaa')">
                                save description </button>
                                </div>








                                function updateDescription(person_name)

                                var person_name= person_name

                                var person_descr= document.getElementById("person_descr");
                                alert(person_name)
                                alert(person_descr.value);
                                person_descr.value = person_name;
                                alert(person_descr.value)

                                <div class="modal-content">
                                <h4 class="modal-title">PersonName</h4>
                                <div id = 'person_name' class="modal-body">
                                <p>aaa</p>
                                </div>
                                <h4 class="modal-title">Person Description</h4>
                                <textarea id="person_descr" style="overflow: scroll; height:
                                100px;"></textarea>
                                <button name="button" type="button" class="save"
                                class="btn btn-info"
                                onClick="updateDescription('aaa')">
                                save description </button>
                                </div>





                                function updateDescription(person_name)

                                var person_name= person_name

                                var person_descr= document.getElementById("person_descr");
                                alert(person_name)
                                alert(person_descr.value);
                                person_descr.value = person_name;
                                alert(person_descr.value)

                                <div class="modal-content">
                                <h4 class="modal-title">PersonName</h4>
                                <div id = 'person_name' class="modal-body">
                                <p>aaa</p>
                                </div>
                                <h4 class="modal-title">Person Description</h4>
                                <textarea id="person_descr" style="overflow: scroll; height:
                                100px;"></textarea>
                                <button name="button" type="button" class="save"
                                class="btn btn-info"
                                onClick="updateDescription('aaa')">
                                save description </button>
                                </div>






                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Mar 25 at 7:15









                                Hien NguyenHien Nguyen

                                8,93841032




                                8,93841032





















                                    0














                                    to get a html text area value, you can use the value property:



                                    document.getElementById("id").value


                                    also you have to escape your html quotes:



                                    <button name="button" type="button" class="save" 
                                    class="btn btn-info"
                                    onClick="updateDescription('<%=person['person_name']%>')">
                                    save description </button>





                                    share|improve this answer



























                                      0














                                      to get a html text area value, you can use the value property:



                                      document.getElementById("id").value


                                      also you have to escape your html quotes:



                                      <button name="button" type="button" class="save" 
                                      class="btn btn-info"
                                      onClick="updateDescription('<%=person['person_name']%>')">
                                      save description </button>





                                      share|improve this answer

























                                        0












                                        0








                                        0







                                        to get a html text area value, you can use the value property:



                                        document.getElementById("id").value


                                        also you have to escape your html quotes:



                                        <button name="button" type="button" class="save" 
                                        class="btn btn-info"
                                        onClick="updateDescription('<%=person['person_name']%>')">
                                        save description </button>





                                        share|improve this answer













                                        to get a html text area value, you can use the value property:



                                        document.getElementById("id").value


                                        also you have to escape your html quotes:



                                        <button name="button" type="button" class="save" 
                                        class="btn btn-info"
                                        onClick="updateDescription('<%=person['person_name']%>')">
                                        save description </button>






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Mar 25 at 7:27







                                        user11251560




























                                            0














                                            Avoid the limitations and awkward syntax of onevent attributes -- use onevent properties or event listeners instead. The following demo uses an onevent property.



                                            BTW the button is invalid it has two class attributes:



                                            <button name="button" type="button" class="save"
                                            class="btn btn-info"

                                            onClick="updateDescription('<%=person['person_name']%>')">
                                            save description </button>



                                            Demo






                                            document.querySelector('.btn').onclick = updateDesc;

                                            function updateDesc(e)
                                            var personName = document.getElementById("personName");
                                            var personDesc = document.getElementById("personDesc");
                                            console.log(personName.textContent);
                                            console.log(personDesc.value);

                                            * 
                                            margin: 0;
                                            padding: 0

                                            <div class="modal-content">
                                            <h4 class="modal-title">Person Name</h4>
                                            <div id='personName' class="modal-body">
                                            <p>
                                            John Doe
                                            </p>
                                            </div>
                                            <h4 class="modal-title">Person Description</h4>
                                            <textarea id="personDesc" style="overflow: scroll; height: 100px;"></textarea><br>
                                            <button name="button" type="button" class="btn btn-info save">Save Description</button>
                                            </div>








                                            share|improve this answer



























                                              0














                                              Avoid the limitations and awkward syntax of onevent attributes -- use onevent properties or event listeners instead. The following demo uses an onevent property.



                                              BTW the button is invalid it has two class attributes:



                                              <button name="button" type="button" class="save"
                                              class="btn btn-info"

                                              onClick="updateDescription('<%=person['person_name']%>')">
                                              save description </button>



                                              Demo






                                              document.querySelector('.btn').onclick = updateDesc;

                                              function updateDesc(e)
                                              var personName = document.getElementById("personName");
                                              var personDesc = document.getElementById("personDesc");
                                              console.log(personName.textContent);
                                              console.log(personDesc.value);

                                              * 
                                              margin: 0;
                                              padding: 0

                                              <div class="modal-content">
                                              <h4 class="modal-title">Person Name</h4>
                                              <div id='personName' class="modal-body">
                                              <p>
                                              John Doe
                                              </p>
                                              </div>
                                              <h4 class="modal-title">Person Description</h4>
                                              <textarea id="personDesc" style="overflow: scroll; height: 100px;"></textarea><br>
                                              <button name="button" type="button" class="btn btn-info save">Save Description</button>
                                              </div>








                                              share|improve this answer

























                                                0












                                                0








                                                0







                                                Avoid the limitations and awkward syntax of onevent attributes -- use onevent properties or event listeners instead. The following demo uses an onevent property.



                                                BTW the button is invalid it has two class attributes:



                                                <button name="button" type="button" class="save"
                                                class="btn btn-info"

                                                onClick="updateDescription('<%=person['person_name']%>')">
                                                save description </button>



                                                Demo






                                                document.querySelector('.btn').onclick = updateDesc;

                                                function updateDesc(e)
                                                var personName = document.getElementById("personName");
                                                var personDesc = document.getElementById("personDesc");
                                                console.log(personName.textContent);
                                                console.log(personDesc.value);

                                                * 
                                                margin: 0;
                                                padding: 0

                                                <div class="modal-content">
                                                <h4 class="modal-title">Person Name</h4>
                                                <div id='personName' class="modal-body">
                                                <p>
                                                John Doe
                                                </p>
                                                </div>
                                                <h4 class="modal-title">Person Description</h4>
                                                <textarea id="personDesc" style="overflow: scroll; height: 100px;"></textarea><br>
                                                <button name="button" type="button" class="btn btn-info save">Save Description</button>
                                                </div>








                                                share|improve this answer













                                                Avoid the limitations and awkward syntax of onevent attributes -- use onevent properties or event listeners instead. The following demo uses an onevent property.



                                                BTW the button is invalid it has two class attributes:



                                                <button name="button" type="button" class="save"
                                                class="btn btn-info"

                                                onClick="updateDescription('<%=person['person_name']%>')">
                                                save description </button>



                                                Demo






                                                document.querySelector('.btn').onclick = updateDesc;

                                                function updateDesc(e)
                                                var personName = document.getElementById("personName");
                                                var personDesc = document.getElementById("personDesc");
                                                console.log(personName.textContent);
                                                console.log(personDesc.value);

                                                * 
                                                margin: 0;
                                                padding: 0

                                                <div class="modal-content">
                                                <h4 class="modal-title">Person Name</h4>
                                                <div id='personName' class="modal-body">
                                                <p>
                                                John Doe
                                                </p>
                                                </div>
                                                <h4 class="modal-title">Person Description</h4>
                                                <textarea id="personDesc" style="overflow: scroll; height: 100px;"></textarea><br>
                                                <button name="button" type="button" class="btn btn-info save">Save Description</button>
                                                </div>








                                                document.querySelector('.btn').onclick = updateDesc;

                                                function updateDesc(e)
                                                var personName = document.getElementById("personName");
                                                var personDesc = document.getElementById("personDesc");
                                                console.log(personName.textContent);
                                                console.log(personDesc.value);

                                                * 
                                                margin: 0;
                                                padding: 0

                                                <div class="modal-content">
                                                <h4 class="modal-title">Person Name</h4>
                                                <div id='personName' class="modal-body">
                                                <p>
                                                John Doe
                                                </p>
                                                </div>
                                                <h4 class="modal-title">Person Description</h4>
                                                <textarea id="personDesc" style="overflow: scroll; height: 100px;"></textarea><br>
                                                <button name="button" type="button" class="btn btn-info save">Save Description</button>
                                                </div>





                                                document.querySelector('.btn').onclick = updateDesc;

                                                function updateDesc(e)
                                                var personName = document.getElementById("personName");
                                                var personDesc = document.getElementById("personDesc");
                                                console.log(personName.textContent);
                                                console.log(personDesc.value);

                                                * 
                                                margin: 0;
                                                padding: 0

                                                <div class="modal-content">
                                                <h4 class="modal-title">Person Name</h4>
                                                <div id='personName' class="modal-body">
                                                <p>
                                                John Doe
                                                </p>
                                                </div>
                                                <h4 class="modal-title">Person Description</h4>
                                                <textarea id="personDesc" style="overflow: scroll; height: 100px;"></textarea><br>
                                                <button name="button" type="button" class="btn btn-info save">Save Description</button>
                                                </div>






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Mar 25 at 7:47









                                                zer00nezer00ne

                                                27k32648




                                                27k32648



























                                                    draft saved

                                                    draft discarded
















































                                                    Thanks for contributing an answer to Stack Overflow!


                                                    • Please be sure to answer the question. Provide details and share your research!

                                                    But avoid


                                                    • Asking for help, clarification, or responding to other answers.

                                                    • Making statements based on opinion; back them up with references or personal experience.

                                                    To learn more, see our tips on writing great answers.




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function ()
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55332649%2fgetelementbyid-not-returning-current-text-from-text-area-in-javascript-function%23new-answer', 'question_page');

                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                                                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                                                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해