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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:09:00+00:00 2026-05-30T23:09:00+00:00

I am currently returning an array and running a for loop through it. The

  • 0

I am currently returning an array and running a for loop through it. The form is supposed to take in the id,screenName and course when submitted. The ajax works. However, it always takes in only the id of the first row only. Without the ajax, i am able to submit the forms for different rows. But i dont want the page to be refreshed every time the button is clicked so i included the ajax part. I am not sure where i am going wrong since i am pretty new to this area. Any help would be appreciated.

<form name ="nominate" action="" id ="nominate"  method="POST">
        <input type="hidden" name="id" id = "Nid" value="<?php echo $id;?>">
        <input type="hidden" name="screenName" id = "screenName" value="<?php echo $screenName;?>">
        <input type="hidden" name="course" id = "course" value="<?php echo $course;?>">
        <input type="image" class="nominate" style="float: left;" onMouseOver="this.src='images/discuss_this_u.png'"
        onMouseOut="this.src='images/discuss_this.png'" value="Place Order" src="images/discuss_this.png"  width="60" height="20">
        </form>



<script> 
  $(function() {
    $(".nominate").click(function() {
     var id = $('#Nid').val();  
    var screenName = $('#screenName').val();
    var course = '<?php echo $course ;?>';
    var section = '<?php echo $section ;?>';

    var dataString = 'id='+ id + '&screenName=' + screenName + '&course=' + course + '&section=' + section;  
    alert(dataString);
    $.ajax({
       type: "POST",
       url: "nominate.php",
       data: dataString,
       success: function(){

       }
    });


    });
  });



</script>
  • 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-30T23:09:01+00:00Added an answer on May 30, 2026 at 11:09 pm

    Change your code below

    var id = $('#Nid').val();
    

    to

    var id = $(this).closest('form').find('input[name=id]').val();
    

    You should also remove the id=”Nid” since id’s can only be used once. If anything it should be a class. The above code checks the closest form element and grabs the id.

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

Sidebar

Related Questions

I currently am dealing with a Web Service that is returning an array of
My REST API returns JSON. I'm currently returning text/plain as the MIME type, but
I currently am returning a table that looks like this: Country Result ------ -----
I have an sql statement that currently is just returning all the end parent
Currently, I have this version of the autocomplete control working when returning XML from
Currently I'm querying the FQL friends_request table but it's returning the empty result... I
I currently have Core Data successfully returning all of the results for a specific
I'm currently running into an issue of needing to pass a SAFEARRAY(GUID) as a
I am currently taking a university course in data structures, and this topic has
If I have an array in PHP that is currently null, shouldn't accessing an

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.