FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » multiple dynamic text fields
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
multiple dynamic text fields [message #177275] Sat, 03 March 2012 13:32 Go to next message
hipa is currently offline  hipa
Messages: 5
Registered: March 2012
Karma: 0
Junior Member
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>
Re: multiple dynamic text fields [message #177277 is a reply to message #177275] Sat, 03 March 2012 14:07 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/3/2012 8:32 AM, hipa wrote:
> 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.
>
<irrelevant code snipped>

You're in the wrong newsgroup. Autocomplete is browser-side. PHP is
server side. Try comp.lang.javascript to start.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: multiple dynamic text fields [message #177317 is a reply to message #177277] Thu, 08 March 2012 18:17 Go to previous messageGo to next message
hipa is currently offline  hipa
Messages: 5
Registered: March 2012
Karma: 0
Junior Member
Op Sat, 03 Mar 2012 09:07:01 -0500, schreef Jerry Stuckle:

> On 3/3/2012 8:32 AM, hipa wrote:
>> 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.
>>
> <irrelevant code snipped>
>
> You're in the wrong newsgroup. Autocomplete is browser-side. PHP is
> server side. Try comp.lang.javascript to start.

Hi

My autocomplete isn't browser side. It gets its values from a postgres DB
on the server. See my post in the group you recommended.
Re: multiple dynamic text fields [message #177318 is a reply to message #177317] Thu, 08 March 2012 20:46 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/8/2012 1:17 PM, hipa wrote:
> Op Sat, 03 Mar 2012 09:07:01 -0500, schreef Jerry Stuckle:
>
>> On 3/3/2012 8:32 AM, hipa wrote:
>>> 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.
>>>
>> <irrelevant code snipped>
>>
>> You're in the wrong newsgroup. Autocomplete is browser-side. PHP is
>> server side. Try comp.lang.javascript to start.
>
> Hi
>
> My autocomplete isn't browser side. It gets its values from a postgres DB
> on the server. See my post in the group you recommended.

It may get the data from a database, but the request must still come
from the browser - which is what your AJAX code is doing.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: XAMPP only works first time
Next Topic: which command to use
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 01:24:55 GMT 2024

Total time taken to generate the page: 0.02438 seconds