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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:04:21+00:00 2026-05-11T08:04:21+00:00

I am looking to grab the value of a form input. I think my

  • 0

I am looking to grab the value of a form input.

I think my problem is on this line:

    var vid = $(this).next('.pid').val(); 

I need to send the value of the input box named ‘pid’ to a php page, however there are several forms on the page, all with input boxes named ‘pid’. When i merely have:

next('.pid').val(); 

the value that is sent is from another form on the page.

Edit: All I am really trying to do is set the ‘data’ to be an array of all of the data in the form. So if there is a better way to set the ‘formdata’ variable to the id of the form, that would work too.

Below is the jQuery function:

$('.varSel').live('change', function(){     var vid = $(this).next('.pid').val();     var formdata = $('form#addToCart'+ vid).serialize();     $.ajax({         type: 'POST',         url: 'library/varPrice.php',         data: formdata,         success: function(html){         $('.price').html(html);       }     }); }); 

EDIT:

Below is a form:

<form name='addToCart' id='addToCart99' action='cart.php?action=add' method='post'>     <ul class='vars' id='varlist_p99'>         <li>         <label for='color'>color</label>          <select id='color' name='color' class='varSel'>             <option>blue</option>             <option>green</option>             <option>red</option>         </select>         </li>          <li>         <label for='size'>size</label>          <select id='size' name='size' class='varSel'>             <option>large</option>             <option>small</option>         </select>         </li>          <li>             <div class='price'>                 $$             </div>         </li>          <li>                 <input type='hidden' value='99' name='pid'>                  <input type='submit' class='buynow' value=''>         </li>     </ul> </form> 
  • 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. 2026-05-11T08:04:21+00:00Added an answer on May 11, 2026 at 8:04 am

    Replace this:

    var vid = $(this).next('.pid').val(); var formdata = $('form#addToCart'+ vid).serialize(); 

    With this:

    var formdata = $(this).parents('form').serialize(); 

    Tested and works.

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

Sidebar

Ask A Question

Stats

  • Questions 73k
  • Answers 73k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer MVC baby! And JQuery! Edit: OK, it's fair enough to… May 11, 2026 at 1:56 pm
  • added an answer Because JSON is a subset of the actual JavaScript literal… May 11, 2026 at 1:56 pm
  • added an answer If you are creating and/or destroying tables programmatically during the… May 11, 2026 at 1:56 pm

Related Questions

I am looking to manage a SQL Server 2008 DB using Management Studio 2005.
I am looking to allow users to control of subdomain of an app I
I am looking to write some C# code for linux/windows/mac/any other platform, and am
I am looking to do this in C/C++. I came across Variable Length Arguments
I am looking to implement a data-driven wizard with the question tree stored in
I've got a problem that keeps coming up with normalized databases and was looking
I seem to be suffering from some fundamental misunderstanding of the way that GWT
I am looking for a way to store a large variable number of matrixes
WOW! That's a weird title, but I'm happy you're looking, cause I couldn't find

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.