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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:28:23+00:00 2026-05-31T19:28:23+00:00

I have a table which is being dynamically populated, each row contains two textfields

  • 0

I have a table which is being dynamically populated, each row contains two textfields which can be edited. When the user click the save button, i want to read al those entered values and updated accordingly:

echo "<td><input value='".$row[0]."' type='hidden'>$sql1[0]</td><td>$sql1[1]</td>
    <td><input type='text' id='disc-".$row[0]."' value='".$row[3]."'></td>

The $row[0] is the ID of that row in the database and $row[3] is the value currently stored. What i am trying to achieve is that once the user clicks save, i read the value entered by the user in the textfield based on the ID so that it can be updated. For that have a javascript that selects those elements:

for(var i = 0; i < $('#order_basket [id |= "disc"]').length; i++) {
    alert($('#order_basket [id|="disc"]')??.val());
}

Now the length returned is correct but i am trying to read in the id and the value which will be further stored in an array.

NOTE: there are more than 1 textfields in the same row, the other textfield has the id='disc-".$row[0]."'

  • 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-31T19:28:24+00:00Added an answer on May 31, 2026 at 7:28 pm

    Try this.

    var values = {};
    $('#order_basket input[id^="disc"]').each(function(){
         values[this.id] = this.value;
    });
    

    Now values object will contain id/value pair of each of the input elements

    Note that I am using attribute starts with selector ^= to find all the input elements

    Update based on OP’s comment.

    var ids = [], values = [];
    $('#order_basket input[id^="disc"]').each(function(){
         ids.push(this.id);
         values.push(this.value);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which is being dynamically populated from MySQL. The table has
I have a datatable being built in code which can dynamically have any given
I have a table form which contains a part where the rows can be
I have a table which contains my server status create table ServerStatus ( ServerId
I have a table which has two varchar(Max) columns Column 1 Column 2 -----------------------
I have a table which has two text boxes and an image beside it
I have a table which defines what things another table can have, for example:
I have a table that is being dynamically repopulated by an ajax call. I
I have a table which contains a bunch of rows and a sort_order .
I have a table which has some nullable fields and when the user enters

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.