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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:50:19+00:00 2026-06-13T08:50:19+00:00

For this demo I am getting inputs from a form, putting them in a

  • 0

For this demo I am getting inputs from a form, putting them in a json object and sending via ajax to a server. How can i repopulate a form with the data on the server? I can get it to print in the console but cant seem to figure out how to get it in a form. is it as simple as putting something like jsonObject.firstName somewhere in the form field?

form:

div class="form">      
      <form method="GET" action="demo.html">  
      <section class="formSection">  
        <div class="dataChunk">
          <label for="firstName">First Name:</label>
          <input type="text"  id="jsonObject.firstName" maxlength="50" />  
        </div>                    
        <div class="dataChunk">    
          <label for="lastName">Last Name:</label>         
          <input type="text"  id="lastName" maxlength="50" />  
        </div>       
        <div class="dataChunk">   
          <label for="phoneNumber">Phone:</label>
          <input type="text"  id="phoneNumber" maxlength="10" />
        </div>             
        <div class="dataChunk">   
          <label for="address">Address:</label>
          <input type="text"  id="address" maxlength="50" />
        </div>  
       </section>                  
    </form> 
  </div>

json object

var jsonObject = {
  "firstName" : firstName, 
  "lastName" : lastName,
  "phone" : phone,
  "address" : address
  };

php

$name = $_REQUEST['firstName']." ".$_REQUEST['lastName'];
$phone = $_REQUEST['phone'];
$address = $_REQUEST['address'];

$person = Array();
$person['name'] = $name;
$person['phone'] = $phone;
$person['address'] = $address;

$returnObj = json_encode($person);
echo $returnObj;
?>
  • 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-13T08:50:20+00:00Added an answer on June 13, 2026 at 8:50 am

    You would need to iterate thru your php json encoded return using $.each and update your form elements by selector

     $(document).ready(function() {
        $('form').submit( function(){
          var values = serialize( $(this) );
          $.ajax({
             url: 'demo.php'
             data: values,
             Success: function(result){
               $.each(result, function( key, value ) ({
                $('#'+key).val(value); 
               });
             }
          });
         });
      });
    

    Untested as i’m on a mobile device, but general layout is there,i’ll update if i make any syntax errors

    placing jsonobject in front of your element id will not auto parse the json returned object

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

Sidebar

Related Questions

I am getting this data from JSON web services [{identity:DEMO,assets:[{identity:34DL3611,systemId:544507},{identity:34GF0512,systemId:5290211},{identity:34HH1734,systemId:111463609},{identity:34HH1736,systemId:111463622},{identity:34YCJ15,systemId:294151155}],systemId:4921244}] I am using this
see this demo from jquery ui you have to hold down the Ctrl key
I ran the code to create the generically related objects from this demo: http://www.djangoproject.com/documentation/models/generic_relations/
Can anyone see why this form is being submitted in the normal fashion and
I am trying to integrate the code from this demo: http://code.google.com/p/gwt-spring-starter-app/ into my main
I'm trying to follow the demo from this link to add a jqGrid to
This demo code loops 3 times and every time appends text. What I need
I've prepared this demo: https://dl.dropbox.com/u/7224702/lists-bug.html It works fine in Firefox, Chrome and IE8 but
When i run this demo it's call TestBean's writeObject method which is private How
Check out this demo by FaTaL. It is explained in his blog that he

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.