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

The Archive Base Latest Questions

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

I have this page that has a variable number of text fields, each named

  • 0

I have this page that has a variable number of text fields, each named item_#### where #### is the ID of the item the text field is representing. I would like to auto-populate these fields with how much of the item is in stock after the user clicks a button. The JSON return wouls look like this:
[#### : 45], [#### : 62]
(note the lack of item_ in the key)

I’m having trouble working my head around how I can load that data into multiple text fields based on the returned results of a php script. I would assume a loop would be in order, however I’m extremely new to Javascript and jQuery, so I’m lost when it comes to loading this content dynamically…

  • 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-23T10:28:10+00:00Added an answer on May 23, 2026 at 10:28 am

    The data format is not clear, but you could do something like this:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
        <title>Simple JSON</title>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />
        <meta name="generator" content="Geany 0.20" />
        <script type="text/Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
        <script type="text/Javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>
        <script type="text/Javascript">
            $(document).ready(function(){
                $('[name="button"]').click(function(){
                    $.get('json.php',function(data){
                        data = $.parseJSON(data);
                        $.each(data,function(i,v){                      
                            $('[name="item-'+i+'"]').attr('value',v);
                        });
                    });
                });
            });
        </script>
    </head>
    
    <body>
        <input name="text-1" />
        <input name="text-4" />
        <input name="button" type="button" value="update" />
    </body>
    
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that has 3 variables. They look like this: String[] Headers
I have this code that fetches some text from a page using BeautifulSoup soup=
I have a JSF page which has a variable number inputText elements containing numeric
I have a single page that has a number of controls configured a certain
I have a page that has 50 elements with the same class fields which
I have an aspx page that uses a master page. On this page I
Please have a look at this demo page that I cooked up a while
I have a page that is setup like this public partial class _Default :
I have a page that is accessed via a URL like this: http://power-coder.net/Test/something.php?id=3#Page1 I
On this page there is a list of footer links that have a little

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.