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 3631728
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:26:04+00:00 2026-05-19T00:26:04+00:00

This is a very simple form that I have found on the web (as

  • 0

This is a very simple form that I have found on the web (as I am a jQuery beginner).

<!-- this is my jquery -->

<script>
    $(document).ready(function(){
$("form#submit_wall").submit(function() {

var message_wall = $('#message_wall').attr('value');
var id = $('#id').attr('value');
$.ajax({
type: "POST",
url: "index.php?leht=pildid",
data:"message_wall="+ message_wall + "&id="+ id,
cache: false,

success: function(){
$("ul#wall").prepend(""+message_wall+"", ""+id+"");
$("ul#wall li:first").fadeIn();

alert("Thank you for your comment!");
}
});
return false;
});
});
</script>

<!-- this is my HTML+PHP -->
some PHP ...
      while($row_pilt = mysql_fetch_assoc($select_pilt)){

       print 

<form id="submit_wall">
<label for="message_wall">Share your message on the Wall</label>
<input type="text" id="message_wall" />
<input type="hidden" id="id" value="'.(int)$row_pilt['id'].'">
<button type="submit">Post to wall</button>
</form>

and down below is my PHP script that
writes to mySQL.

It is a pretty straight forward script. However, it is getting little complicated when I submit it. Since I have more than one form on my page (per WHILE PHP LOOP), thus when I submit – only the FIRST form gets submitted. Furthermore, any other subsequent forms that I submit – data is being copied from the first form.
Is there any jQuery functions that clear the data? – or is there a better solution.

Thanks,
Nick

  • 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-19T00:26:04+00:00Added an answer on May 19, 2026 at 12:26 am

    It’s because you’re giving each form the same id, and thus it is submitting the first element it finds with that id, i.e. the first form. What you should do is assign a unique id to each form, and then give each form an AJAX submit function that submits the form-specific data. You can use jQuery’s $.each() function to loop through all the forms and $(this).attr(‘id’) within the submit function to retrieve the form-specific id.

    UPDATE: As revealed by the comment on this answer, you actually don’t need the each() function because jQuery applies it to every form element anyway.

    Here would be an example script:

    $(document).ready(function(){
        $("form").submit(function() {
            var message_wall = $(this).children('input[type="text"]').attr('value');
            var id = $(this).children('input[type="hidden"]').attr('value');
            $.ajax({
                type: "POST",
                url: "index.php?leht=pildid",
                data:"message_wall="+ message_wall + "&id="+ id,
                cache: false,
                success: function(){
                    $("ul#wall").prepend(""+message_wall+"", ""+id+"");
                    $("ul#wall li:first").fadeIn();
                    alert("Thank you for your comment!");
                }
            });
           return false;
       });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a very simple web part that accepts entry on a form
I've written this very simple function to replace a file extension using LINQ in
Have a look at this very simple example WPF program: <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
I have very simple select like this: SELECT * FROM table WHERE column1 IN
I have a very simple application with a form, a richedit and a menu.
Ok, I have a model that is very simple: ServiceType(id: integer, title: string, duration:
Very simple I have this: for i in self.Abilities: i.OnTimer(amount) Can i have something
This very simple code gives me tons of errors: #include <iostream> #include <string> int
i am trying to compile this very simple piece of code class myList {
This is a very simple question with a simple answer, but it is not

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.