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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:19:23+00:00 2026-05-24T16:19:23+00:00

I am having a PHP (HTML) page with 2 buttons.One button is used to

  • 0

I am having a PHP (HTML) page with 2 buttons.One button is used to get information(button 1) and the other button is used to submit the information(button 2).Both these buttons are linked to one form field called id.

when user enters the id and presses the get button(button 1) all the information about that id(name,age…) will be fetched from the database and will be displayed on the same html page(i used jquery for this).

button 2(submit)
When the user wants to submit the information the user enters the id and details in the other form boxes(name,age.. form boxes) and then clicks submit button, all the information entered about the id will be submitted to database.

All the above stuff works fine for me and here is the snippet of the code i used.

<html>
<head>
<script type="text/javascript" src="jquery.js"></script> 
<script type="text/javascript">
//get information from DB using script_1.php
$(document).ready(function(){
$("#button1").click(function(){
    $.post('script_1.php', { name: $('input[name$="name"]', '#myForm').val() },
        function(output) {
            $('#age').html(output).show();
        });
});
//submit info to DB using script_2.php
$("#button2").click(function(){
    $('form#myForm').attr({action: "script_2.php"});
    $('form#myForm').submit();
});
});

</script>
</head>
<body>
<form id="myForm" method="post">
id: <input type="text" name="name"/>
<input type="button" id="button1" value ="Get"/>
<input type="button" id="button2" value="Submit to script 2" />
name:<input type="text" name="title"/>
age:<input type="text" name="title"/>
</form>
<div id="age"></div>
</body>
</html>

Here is my QUESTION or PROBLEM

Only related to get button(button 1)

The information i am getting from the database using get button(button 1) is displayed at the bottom of the same html page, Instead what i want to do is the information fetched should be displayed in the respective form box i.e., when the user submits the id the information about the id like name and age should be displayed in the respective form boxes.(example name should be displayed in name: )

How can i do this? any suggestions or some good tutorials relating to the following will be highly appreciated.

Thanks for your time. John

  • 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-24T16:19:24+00:00Added an answer on May 24, 2026 at 4:19 pm

    This is not difficult. You will need to modify your PHP script to send JSON to the client. You will then need to insert the values from the received JSON into the form elements one by one. Example to get you started:

    $("#button1").click(function(){
        $.post('script_1.php', { id: $('input[name="id"]', '#myForm').val() },
            function(json) {
                $("input[name='name']").val(json.name);
                $("input[name='age']").val(json.age);
            }, "json");
    });
    

    PHP:

    $data = array('name' => 'Jeff', 'age' => '28');
    echo json_encode($data);
    

    For clarity, I’ve modified your form elements’ names:

    <form id="myForm" method="post">
    id: <input type="text" name="id"/>
    <input type="button" id="button1" value ="Get"/>
    <input type="button" id="button2" value="Submit to script 2" />
    name:<input type="text" name="name"/>
    age:<input type="text" name="age"/>
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how can i pass parameters from an html page(map.html) to a php(createxml.php) without having
Trying out some things with php and html, I'm having issues trying to get
I am having a php file which executes some code to generate a html
I am using HTML Purifier in my PHP project and am having trouble getting
I am having one problem with the PHP json_encode function. It encodes numbers as
I am having C function. From the html page, through ajaxcall the request is
I have a PHP page which generates an HTML table. At the bottom of
I am parsing an HTML page with DOM and XPath in PHP. I have
I'm trying to determine the best way of having a PHP script determine which
Having been a PHP developer on LAMP servers for quite a while, is there

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.