Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3398604
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:40:11+00:00 2026-05-18T04:40:11+00:00

I am using a dialog with a textarea. Upon clicking the ok-button the textarea’s

  • 0

I am using a dialog with a textarea. Upon clicking the ok-button the textarea’s value gets sent to a server via ajax.
The first time the user writes to the textarea the value gets read correctly, but upon all subsequent actions the value being sent is the same as the first time as if the user had entered the same string over and over again.

function message(url) { 
  var mydiv; 
  mydiv = $(document.createElement('div')); 
  mydiv.html("enter message: <textarea name='message' id='message'/>"); 
  mydiv.dialog(setProps(url));
  mydiv.dialog('open');
}

function setProps(url) {
  return {
    buttons: {
      "ok": function() {
        $.get('/act?url=' + url + '&message=' + $("#message").val().trim(),
          function(data) { 
            $("#content").load('/react?url=' + url); 
          }
        ); 
        $(this).dialog("close"); 
        $(this).dialog("destroy"); 
        // If I use the following all subseq. actions are empty:
        // $("#message").val(''); 
      }
    } 
  } 
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:40:12+00:00Added an answer on May 18, 2026 at 4:40 am

    When you create a dialog it gets appending at the end of the <body>, just because you’re destroying the dialog doesn’t mean the elements in it go away, they’re just returned to their location, or in this case still at the end of the <body>, you also need to .remove() those elements, like this:

    $(this).dialog("destroy").remove();
    

    Otherwise (currently) you’re adding a new #message element each time, and what you’re seeing is a classic duplicate ID issue, it’s getting the value of the first one (the first you appended…that never left).


    Overall there are a few more issues, for example IE<9 not having String.prototype.trim() so your value would blow up, as would having anything like & in it. Let jQuery encode your values, like this:

    function message(url) { 
     $("<div>enter message: <textarea name='message' id='message'></textarea></div>")
       .dialog(setProps(url));
    }
    
    function setProps(url) {
      return {
        buttons: {
          "ok": function() {
            $.get('/act', { url: url, message: $.trim($("#message").val()) },
              function(data) { 
                $("#content").load('/react?url=' + url); 
              }
            ); 
            $(this).dialog("destroy").remove(); 
          }
        } 
      } 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im using jqueryui dialog but there's a problem upon loading it from other file.
I am using a dialog as a loading overlay for various AJAX functions, but
I am using the latest version 3.4.b3. I have it in a dialog and
Using jQuery UI , I have a tabs plugin and within tab 1 gets
I'm actually using JQueryUI Dialog plugin to show some information to the users of
I am using jQuery .dialog() in my code. In dialog i am having Form.
I'm using Theme.Dialog on one of my activities. I'm using setTitle(mMyTitle) to set the
I am using Jquery dialog box(jquery-ui-1.8.11.custom.min.js). The source for this dialog box is an
I am using Jquery dialog to show radgrid. I have set AllowFilteringByColumn to true
I have 2 simple pages. Index contains a hyperlink with an anchor tag which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.