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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:45:45+00:00 2026-06-09T03:45:45+00:00

I am programming a insurance form: you select the company you have, then it

  • 0

I am programming a insurance form: you select the company you have, then it will access the phone number and other values from the database and fill in the form below. Then they just need to enter in their info that’s required.

$hostname = "";
$username = "";
$password = "";
$database = "";

mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

//getFN();
function getFN()
{
    $query = "SELECT first FROM contacts";
    $FNresult = mysql_query($query); 


    $dropdown = "<select name='contacts'>";

    while( $row = mysql_fetch_assoc($FNresult) )
    {
        $dropdown .= "\r\n<option value='{$row['first']}'>{$row['first']}</option>";
        echo getLN();
        //$last .="\r\n<option value='{$row['last']}'>{$row['last']}</option>";
        //echo $last;
    }

    $dropdown .= "\r\n</select>";

    echo $dropdown;
}

// Get last name
function getLN()
{
    $query = "SELECT last FROM contacts";
    $LNresult=mysql_query($query);

    $last;
    while($row = mysql_fetch_assoc($LNresult))
    {
        $last = "{$row['last']}";
    }
    echo $last;
} //end getLN


mysql_close();
?>

<select name="fdsfd" onchange="document.getElementById('first').value = this.value">
    <!-- <option value="<?//php echo $first; ?>"></option>-->
</select>

<form action="insert.php" method="post">
    First Name: <input type="text" id="first" value=""><br>
    Last Name: <input type="text" id="last"><br>
    Phone: <input type="text" id="phone"><br>
    Mobile: <input type="text" id="mobile"><br>
    Fax: <input type="text" id="fax"><br>
    E-mail: <input type="text" id="email"><br>
    Web: <input type="text" id="web"><br>
    <input type="Submit">
</form>
  • 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-09T03:45:48+00:00Added an answer on June 9, 2026 at 3:45 am

    You’ll need to use a combination of AJAX and PHP, and modify the page source dynamically, based on the response from the server (DHTML).

    First, you’ll need an understanding of AJAX: SO question on how AJAX works

    Second, you’ll need an understanding of jQuery: tutorial here

    NOW THEN,

    You’ll need a way for javascript to uniquely identify your element. Give it an id attribute, as well as the name you have given it.

    Once an element has an id attribute, jQuery can access it using the ID selector

    $("#[id]")...
    

    Your background script should take a unique identifier from your dropdown, get the data from your database and populate a JSON-encoded array.

    Then you can populate the form elements.

    <?php
    // background script
    
    // retrieve data based on $_POST variable, set to $returnArray
    
    /****************************
     * the structure of returnArray should look something like
     *     array(
     *         'first' => firstName,
     *         'last' => lastName,
     *         etc.
     *     )
     */
    
    echo json_encode($returnArray);
    

    =========================

    <!-- javascript on client-side -->
    <script language="javascript" type="text/javascript">
        $("#dropdown").on('change', function() {
            $.post("backgroundScript.php", {
                    uid: $(this).val()
                } function(data) {
                   $("#first").val(data.first);
                   $("#last").val(data.last);
                   // etc.
                }, 'json'
            );
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The only object oriented programming experience I have is from C#, so PHP is
In this example from The Ruby Programming Language (p.270), I'm confused why the instance_eval
Programming language: Java Ok, so I want to have a BufferedImage that keeps rotating
My programming background comes from C and some C++ programming with strong emphasis on
i have a modeless form. When the user is done with it, and they
Programming Environment: Visual Studio 2010 Programming Language: VB.NET I have a tabbed web-browser that
I'm new to programming and have some questions about classes. I'll use Karel as
I asked this question earlier but regarding another programming languages. Let's say I have
I have a win form app with a listbox displaying methods (by attribute). I
A simple question regarding multhreading programming: I have an NSMutableArray instance variable that is

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.