0

A div contains a table with 3 rows, a textarea and a button. Using JSON the 3 rows display the correct info but the textarea is showing blank. I want it to display the previous record in the DB.

 function ChangeLoadingImage(CommentSuccessfullyUpdated) {
            if (CommentSuccessfullyUpdated != "FALSE") { 
                var x = jQuery.parseJSON(CommentSuccessfullyUpdated);

                $("#Item").text(x.Item);
                $("#Description").text(x.Description);
                $("#Price").text(x.Price);
                $("#ExistingComments").text(x.ExistingComments);
            }
            else if (CommentSuccessfullyUpdated == "False") {
                showLoadingImage.src = "../Images/X.png";
            }
        }


    <div id="dialog" title="Comments"  style="display:none;">
     <table class="detailstable FadeOutOnEdit">
         <tr>
            <th>Item</th>
            <th>Description</th>
            <th>Owed</th>
         </tr>
         <tr>
             <td id="Item"></td>
             <td id="Description"></td>
             <td id="Price"></td>
         </tr>
     </table> 


     <br />
           <textarea id="ExistingComments" type="text" runat="server" rows="7"
            maxlength="2000"> </textarea> 

            <input id="SubmitComment" type="button" value="Submit"
                onclick="SubmitButton()" />                          
    </div>

All the correct values are returning in the string. But instead of naming the td, iv named the textarea, but it isn't showing up. Any ideas as to why?

String result = "{" + string.Format("\"Item\": \"{0}\", \"Description\": \"{1}\", \"Price\": \"{2}\", \"ExistingComments\": \"{3}\"", Item, Description, Price, ExistingComments) + "}";

          return result;

----------------------------------------------------------------------------------------------

EDIT: I have also tried alert(x.ExistingComments); which does display the correct text. Also tried $("textarea#ExistingComments").text(x.ExistingComments);which does nothing??

2 Answers 2

2

Using JSON the 3 rows display the correct info but the textarea is showing blank.

You can not call text() on textarea rather you need val()

Change

 $("#ExistingComments").text(x.ExistingComments);

To

 $("#ExistingComments").val(x.ExistingComments);
Sign up to request clarification or add additional context in comments.

Comments

0
$('textarea').filter('[id*=ExistingComments]').val(x.ExistingComments);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.