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

  • Home
  • SEARCH
  • 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 4095976
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:58:41+00:00 2026-05-20T19:58:41+00:00

i have a text field <input type=text class=text id=txt_sh_vid onKeyPress=vhc_record() maxlength=4> when i pressed

  • 0

i have a text field

<input type="text" class="text" id="txt_sh_vid" onKeyPress="vhc_record()" maxlength="4">

when i pressed key it will call a function i js

function vhc_record()
{
var  data='vhc='+document.getElementById('txt_sh_vid').value;
 loadXMLDoc('ship/vehicle_ship/','div_vhc',data);
   document.getElementById('div_vhc').style.visibility="visible";
}

it will take the text field value and search a result from database

<?php 
$vhc=$_POST['vhc'];
$con=mysql_connect("localhost","root","");
if(!$con)
{
die ("error".mysql_error());
}
$db_found=mysql_select_db("oil",$con);
if($db_found)
{


$qry="select * from vehicle where vehiclenumber like '$vhc%'";
$result=mysql_query($qry);
echo "<table class='select'>
<tr>
<th>id</th>
<th>vehiclenum</th>
<th>capacity</th>
<th>owner</th>

</tr>
";

while($r = mysql_fetch_assoc($result)){

    echo"<tr onclick='vhc_inv()'>";
    echo"<td id='vhcid'>" .$r['vehicleid']."</td>";
echo"<td id='vhcl'>" .$r['vehiclenumber']."</td>";
echo"<td>".$r['capacity']."</td>";
echo"<td>".$r['owner']."</td>";
echo "</tr>";}
echo "</table>";


}


mysql_close($con);

the orignal problem is that it will show the whole table on first keypress and on second key press it will take the firstkeypressed value as a search
let suppose
when i write n in textfield it will show the whole vehicle table and when i pressed k then it will show only the record having vehicle number starting from n.and when i pressed any other letter then it will show only the record having vehiclenumber=nk
*i want it that when i press n in text field it will only show the record of vehicles having vehicle number starting from n*

  • 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-20T19:58:42+00:00Added an answer on May 20, 2026 at 7:58 pm

    Try to use onKeyUp event instead of onKeyPress

    for example:
    <input type="text" class="text" id="txt_sh_vid" onKeyUp="vhc_record()" maxlength="4">

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

Sidebar

Related Questions

I have this: <input type=text value=Enter Password class=password /> ... onclick/onfocus, I'd like to
I have an input box like the following: <input type=text value= somethingSpecial=filename.txt id=myID class=box>
I have a text input field like text box or text area. I want
I have an input (text field) in update panel, and it autopostbacks after each
I have an input text field, which has a value something by default, but
I have an input text field which has style: visibility: visible or style: visibility:
Newbie question... The objective: I intend to have an HTML text input field as
I have 1 div and 1 text input field, the div is visible and
I have a jQuery jPicker colorpicker that is bound to an input text field
Dear community members, I have a small problem, which involves a text input field

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.