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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:16:33+00:00 2026-06-07T11:16:33+00:00

I am teaching my self php and mysql.I am creating a small commerce site

  • 0

I am teaching my self php and mysql.I am creating a small commerce site to test my skills.
I have mutiple forms on page like this

<div class="formInfo"><form name="CartForm" method="post" action="./ajax/addCart.php" class="fixed">
<input name="prodId" type="hidden" value="10" />
  <label for="qty">Quantity:</label>

  <input name="qty" type="text" id="qty" size="4" maxlength="6" class="qtyBox">
  <br>
  <input type="submit" name="addtoCart" id="addtoCart" value="Add to Cart" class="btnAdd">
</form>



<div class="formInfo"><form name="CartForm" method="post" action="./ajax/addCart.php" class="fixed">
<input name="prodId" type="hidden" value="7" />
  <label for="qty">Quantity:</label>

  <input name="qty" type="text" id="qty" size="4" maxlength="6" class="qtyBox">
  <br>
  <input type="submit" name="addtoCart" id="addtoCart" value="Add to Cart" class="btnAdd">
</form>


<div class="formInfo"><form name="CartForm" method="post" action="./ajax/addCart.php" class="fixed">
<input name="prodId" type="hidden" value="9" />
  <label for="qty">Quantity:</label>

  <input name="qty" type="text" id="qty" size="4" maxlength="6" class="qtyBox">
  <br>
  <input type="submit" name="addtoCart" id="addtoCart" value="Add to Cart" class="btnAdd">
</form>

Now when I click sumbit button I want to show the values of hidden field id and visible field qta (of currently clicked form)
so far my code is

<script type="text/javascript">
$(document).ready(function(e) {
    $('.formInfo').submit(function() {
        alert($(this).val())
    });
});
</script>

I can not figure out.How to tell jquery that I want values of “id” and “qty” of ‘this’ reference not the value of reference itself

  • 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-06-07T11:16:35+00:00Added an answer on June 7, 2026 at 11:16 am

    As stated in previous answers ids should be unique, you need to bind submit to the form not a div, you can access form members by their name from the form element

    $(document).ready(function(e) {
        $('.formInfo form').submit(function() {
            alert(this.prodId.value);
            alert(this.qty.value);
        });
    });
    

    FIDDLE

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm self teaching myself to do MySQL and PHP. It is a new world
I've taught myself Obj-C, and have been self-teaching Cocoa, but adding Core Data to
Teaching myself the flow of data from mySQL -> PHP -> JSON / Javascript
I'm teaching myself Django and creating a personal portfolio site. I've setup a model
I currently have a model set up like so: I have a Test class
Just doing a bit of self teaching on visual basic, I have a list
I am self teaching myself some python OOP, and I have created a simple
I am writing (as a self-teaching exercise) a simple STL-Like range. It is an
Hi I'm new to this. My self-teaching project is a small application which plays
I'm teaching my self Qt; in the same time I don't want to lose

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.