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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:42:37+00:00 2026-06-08T06:42:37+00:00

I need some help regarding making a form using PHP, MySQL, and jQuery. Here

  • 0

I need some help regarding making a form using PHP, MySQL, and jQuery.

Here is my HTML and PHP structure of form:

<form>
    <label>Employee Name</label>
    <input name="empid" type="text" id="search"  <?php  if (!empty($empid))echo "value='$empid'"; ?>>
    <label>Leave Type</label>
    <select name="leavetype" id="leavetype">
        <option value="">--SELECT--</option>
        <?php Loadlookup("id","leavetype","tbl_leavetypes",$leaveid,$d); ?>
    </select>
    <label>Leave Balance</label>
    <input id="autopopulate" value="">
    <input type="submit">
</form>

I am using autocomplete for finding the employee’s name. How do I get both the name and ID of employee by autocomplete, and only show the employee’s name in input, but the ID in some hidden field? Here is my autocomplete code in PHP:

require_once "config.php";
$q = strtolower($_GET["q"]);
if (!$q) return;

$sql = "select DISTINCT FullName as FullName from prmember where FullName LIKE '%$q%'";
$rsd = mysql_query($sql);
while($rs = mysql_fetch_array($rsd)) {
    $cname = $rs['FullName'];
    echo "$cname\n";

and this is the jQuery code for autocomplete:

<script type="text/javascript">
$().ready(function() {
    $("#search").autocomplete("search/search.php", {
        width: 260,
        matchContains: true,
        //mustMatch: true,
        //minChars: 0,
        //multiple: true,
        //highlight: false,
        //multipleSeparator: ",",
        selectFirst: true,


    });
});
</script>

After that, take a look at my HTML form code. when I change <select> in my form, then I want to auto populate the value of <input id="autopopulate" value=""> from the database.

It will be very helpful if you provide all code.

  • 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-08T06:42:38+00:00Added an answer on June 8, 2026 at 6:42 am

    try the following and check this for more details

    $('#leavetype').onchange(function(){
    
    var lvType = $(this).val();
    
        $.get("search.php?q="+lvType, function(data){
           $('#autopopulate').val(data);
        });
    
     }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help here, I have two questions regarding Qt's style sheet customization
I need some help regarding using argparse. What I want to achieve is that
I need some help regarding jquery arrays. var queryArr; $(markersArray).each(function(index) { var _locationId =
I need some help regarding RSS feeds. I need all the RSS feeds data
I need some help regarding the arrays in Perl This is the constructor I
I need your help in JAVA (with some sample code if possible) regarding to
I am a newbie in NSIS. I need some help regarding the MUI Components
I need some help regarding Visual Studio solution and project organization. I have a
I need some help regarding algorithm for randomness. So Problem is. There are 50
I am using unity 2.0 with MVC3 and need some help understanding the LifeTimeManagers.

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.