Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #5091

multiple dynamic text fields

From hipa <hipa.invalid@telenet.be>
Newsgroups comp.lang.php
Subject multiple dynamic text fields
Date 2012-03-03 13:32 +0000
Organization Aioe.org NNTP Server
Message-ID <jit6gs$fe8$1@speranza.aioe.org> (permalink)

Show all headers | View raw


Hi

I have a page with an autocomplete text field. This works fine. But what 
I actually want is adding more text fields with the same autocomplete 
options. It must be an orderpage with multiple order lines.
If I choose option 2 from the drop down, 2 text fields are chown. That is 
ok, but the autocomplete doesn't work.
But if I manually type "getuser.php?q=2" in a browser I get a page with 2 
text boxes where the autocomplete does work.
I don't think I need to show here my complete autocomplete code because I 
think this is not the point here.
When text boxes are generated dynamically is there an underlying id or 
something given to it? Hope someone can help.

index.php
---------

<!DOCTYPE html>

<html lang="en" >
    <head>
        <meta charset="utf-8" />
        <title>Test</title>
        <link href="css/main.css" rel="stylesheet" type="text/css" />   
	<link href="css/jquery.autocomplete.css" rel="stylesheet" 
type="text/css" />
        <script type="text/javascript" src="js/jquery-1.5.2.min.js"></
script>
        <script type="text/javascript" src="js/
jquery.autocomplete.pack.js"></script>
        <script type="text/javascript" src="js/scriptpg.js"></script>

<script type="text/javascript">
function showUser(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
<select name="users" onchange="showUser(this.value)">
<option value="">Select a number:</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</form>
<br />
<div id="txtHint"><b>Number info will be listed here.</b></div>
</body>
</html>

---------------------------------------------------------------

getuser.php
-----------

...

<body>
<?php
$q=$_GET["q"];
for($i=1;$i<=$q;$i++){
echo "<input class='article' type='text' autocomplete='off'><br>";
}
?>
</body>

Back to comp.lang.php | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

multiple dynamic text fields hipa <hipa.invalid@telenet.be> - 2012-03-03 13:32 +0000
  Re: multiple dynamic text fields Jerry Stuckle <jstucklex@attglobal.net> - 2012-03-03 09:07 -0500
    Re: multiple dynamic text fields hipa <hipa.invalid@telenet.be> - 2012-03-08 18:17 +0000
      Re: multiple dynamic text fields Jerry Stuckle <jstucklex@attglobal.net> - 2012-03-08 15:46 -0500

csiph-web