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

  • SEARCH
  • Home
  • 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 6235049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:36:13+00:00 2026-05-24T10:36:13+00:00

I still have some problems with jQuery. If I have html like this: <form

  • 0

I still have some problems with jQuery. If I have html like this:

<form method="post">
    <textarea id="id_content" rows="10" cols="40" name="content"></textarea>
    <input id="yes" type="submit" value="submit">
</form>
<form method="post">
    <textarea id="id_content" rows="10" cols="40" name="content"></textarea>
    <input id="no" type="submit" value="submit">
</form>
<form method="post">
    <textarea id="id_content" rows="10" cols="40" name="content"></textarea>
    <input id="question" type="submit" value="submit">
</form>

Why can’t I successfully post a request with this jQuery code?

$(function(){
    $('input').live('click', function(){
        if ($(this).attr('id') == 'yes'){
            var url = 'www.example.com/add_yes/' 
        } if ($(this).attr('id') == 'no'){
            var url = 'www.example.com/add_no/' 
        } else {
            var url = 'www.example.com/add_question/'} 

    var form = $('.' + $(this).attr('id'))
    var textarea = form.$('texarea[name="content"]').text().serialize()

    $.ajax({
    type: 'POST',
    url: url,
    data: textarea,
    success: succes,         
    dataType: 'json'
    })})})

And here is this code in jsfiddle http://jsfiddle.net/

  • 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-24T10:36:14+00:00Added an answer on May 24, 2026 at 10:36 am

    Give a unique class to all of your text area i am using class = ‘content ‘

            <form method="post">
                <textarea id="id_content" rows="10" cols="40" class="content" name="content"></textarea>
                <input id="no" type="submit" value="submit">
            </form>
            <form method="post">
                <textarea id="id_content" rows="10" cols="40" class="content" name="content"></textarea>
                <input id="question" type="submit" value="submit">
            </form>        
    

    Then use this jquery code , this will solve your problem

        $(function(){        
              $('input').live('click', function(){
                   if ($(this).attr('id') == 'yes'){
                        var url = 'www.example.com/add_yes/' 
                   } if ($(this).attr('id') == 'no'){
                        var url = 'www.example.com/add_no/' 
                   } else {
                        var url = 'www.example.com/add_question/'} 
    
              var textarea = $(this).parent().find(".content").val();
    
                   $.ajax({
                     type: 'POST',
                     url: url,
                     data: textarea,
                     success: succes,         
                     dataType: 'json'
                   });
             });
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with some text-inputs: login, password. If user sees this form
I have a some html being generated by JQuery on a Share Point page.
I have some weird problems with jQuery ajax. I am calling jQuery ajax function
I've read some docs about the .NET Garbage Collector but i still have some
im currently learning python (in the very begining), so I still have some doubts
Why can't I browse deeper into the folder, I still have some folders there:
I have some old code (an old but still maintained VB6 application) that from
I still have a large number of floppies. On some of them there probably
I've used ( and still use ) mercurial and git. I have some repos
I have done some work with Ruby on Rails but am still not comfortable

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.