Vignesh
Vignesh

Reputation: 215

Updating textarea does not get submitted in form

i am developing chrome extension in google calendar. The description of the meeting is updated through jquery as shown below,

 <div class="ui-sch">
    <textarea id=":24" name=":24" class="textinput" style="overflow: hidden; resize: vertical;" rows="3" aria-labelledby=":13.descript-label">
    </textarea>
    </div>

 var el= document.getElementsByClassName("textinput");
for(i=0; i < el.length; i++) 
{ 
    if(el[i].type == "textarea")
    {   
        el[i].value="sample description";
    }
}

The content gets updated to the textarea as expected. but when we submit the form, the description is not submitted. Where as if we manually press enter after updating the content, the updated value from javascript is submitted.

I suspect, the data change in description box is binded to another variable. How to update the data change in desc to the form submission ?

update : Steps to simulate

  1. open calender.google.com
  2. click create meeting paste the above
  3. javascript in your console. (observe the value of description field)
  4. Now click save (the meeting description will not be saved if you open the meeting)

  5. Now create a meeting and follow the above steps 1-3.

  6. click on the description box and hit enter or any other character.
  7. Save the meeting. (The description is saved to the meeting)

Upvotes: 1

Views: 93

Answers (2)

Pinke Helga
Pinke Helga

Reputation: 6682

In your example page, it seems as the Google API only recognizes changes when it listens a change event. You can simulate it by

el[i].dispatchEvent(new Event('change'));

Upvotes: 2

Michele P
Michele P

Reputation: 206

not verified, just a suggestion:

if(el[i].type == "textarea")
    {   
        el[i].value="sample description";
        el[i].onchange();
    }

Upvotes: 0

Related Questions