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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:00:49+00:00 2026-06-17T20:00:49+00:00

I would really appreciate if someone can help me with this code. I have

  • 0

I would really appreciate if someone can help me with this code.
I have input fields that are created dynamicly by clicking on link.
The autosuggest works fine only on the first one – the static input field, but I can’t make it work on the dynamic ones.

Here is the HTML code :

<tr>
  <td><label for="addassureed">Additional Assured</label></td>
 <td>
  <div class="wrapSearch">
  <div>
 <input type="text" name="addassured[]" class="input1" id="addassured" size="45" maxlength="1000" onkeyup="autoSuggest(this.id, 'listWrap2', 'searchList2', 'addassured', event);" onKeyDown="keyBoardNav(event, this.id);" />
 <a href="#" onClick="addInput('dynamicInput');" /><img src="../../img/add.png" height="16" width="16" /></a>
      </div>
      <div class="listWrap" id="listWrap2">
      <ul class="searchList" id="searchList2">
       </ul>
       </div>
       </div>
</td>

The code for creating the Input fields:

var counterAssured = 1;
var limit = 10;
function addInput(divName){ 
 if (counterAssured == limit)  {
      alert("You have reached the limit of adding " + counterAssured + " inputs");
 } else {
      var newdiv = document.createElement('div');
      newdiv.innerHTML = " <td><label>Additional Assured " + (counterAssured + 1) + "</label></td><td><input type='text' name='addassured["+counterAssured+"]' class='input1'></td>";
      document.getElementById(divName).appendChild(newdiv);
      counterAssured++;
}
}

And the php code for querying the db : autosuggest.php

$dbhost = 'localhost';  // Database Host
$dbuser = '';       // Database Username
$dbpass = '';           // Database Password
$dbname = '';      // Database Name

$limit = 20;
if (!isset($_POST['itemCode']))
exit;
$input = trim($_POST['itemCode']);


$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname);

$sql = "SELECT company_name FROM contacts WHERE company_name LIKE  '".$input."%' LIMIT $limit";

$result = mysql_query($sql);
if (!$result || !mysql_num_rows($result))
 exit;
 include_once "headers.php";
 echo "<response>";
 while ($row = mysql_fetch_array($result))
 {
$keywords = $row['company_name'];
 echo "<keywords>". $keywords ."</keywords>";       
 }
echo "</response>";
  • 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-17T20:00:50+00:00Added an answer on June 17, 2026 at 8:00 pm

    You missed these two events [ onkeyup& onKeyDown] in the dynamically created fields

    Try this,

    newdiv.innerHTML = ' <td><label>Additional Assured ' + (counterAssured + 1) + '</label></td><td><input type="text" name="addassured['+counterAssured+']" class="input1" onkeyup="autoSuggest(this.id, \'listWrap2\', \'searchList2\', \'addassured\', event);" onKeyDown="keyBoardNav(event, this.id);"></td>';
    

    or with alternate quote syntax:

    newdiv.innerHTML = " <td><label>Additional Assured " + (counterAssured + 1) + "</label></td><td><input type=\"text\" name=\"addassured["+counterAssured+"]\" class=\"input1\" onkeyup=\"autoSuggest(this.id, 'listWrap2', 'searchList2', 'addassured', event);\" onKeyDown=\"keyBoardNav(event, this.id);\"></td>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would really appreciate any help I can get with this. I am having
I would really appreciate if you could shed light on this problem. I have
Really hoping someone can help me with this. I'm building a PHP / MySQL
Maybe there's someone out in the ether that can help me with this one.
Really hoping someone can help with this. I'm sure there are better ways to
I would really appreciate any jquery expert help as a method I've used previously,
I would really appreciate it if some of you could help optimize my tables,
I would really appreciate if you would take a look at this piece of
I would really appreciate any help with the following problem: I need to be
I'm very new to C++ and would really appreciate any and all help. I

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.