Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #12508
| From | hipa <hipa.invalid@telenet.be> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: multiple dynamic text fields |
| Date | 2012-03-08 18:14 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <jjasus$a5t$1@speranza.aioe.org> (permalink) |
| References | <jivp14$brm$1@speranza.aioe.org> <k3b8l7pp4vorvia9lbtutsmbp780hpdra6@4ax.com> |
Op Mon, 05 Mar 2012 14:33:29 +1100, schreef Jeff North:
> On Sun, 4 Mar 2012 13:00:20 +0000 (UTC), in comp.lang.javascript hipa
> <hipa.invalid@telenet.be>
> <jivp14$brm$1@speranza.aioe.org> wrote:
>
>>| Hi
>>|
>>| I posted this question in comp.lang.php but I got redirected here. | 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.
>
> Maybe it doesn't work due to the attribute autocomplete='off'
If I remove the autocomplete='off', the result is the same.
>>| 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.
>
> Your are running the php code directly. It has no DTD and therefore the
> content is displayed in quirks mode. It is highly probable that the
> browser doesn't understand the autocomplete attribute but is using it's
> own autocomplete/autofill option.
>
> Browsers have had this option for years so it would be interesting to
> see if this attribute will override the browser setting (I doubt it
> though).
Is have a DTD, but I didn't show it in this post. See the three dots
(...).
On the other hand, my autocomplete gets the results from a postgres
database. This 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.
>
> You need to specify this information when the element is created (see
> getuser.php for alteration).
When I do it like this:
for($i=1;$i<=$q;$i++){
echo "<input id='article" . $i . "' name='article" . $i . "'
type='text'>";
}
The same happens. It does work if I manually type "getuser.php?q=2" in a
browser. But not when I open the page from the index page.
>>|
>>| index.php
>>| ---------
>
> Why are you mixing HTML5 and XHTML elements? For example, the link
> element does not have a closing element, only in XHTML is the />
> required.
>
> In HTML5 you can shorten your script elements by using <script></script>
> i.e.
> <script src="js/jquery-1.5.2.min.js"></script> <script
> src="js/jquery.autocomplete.pack.js"></script>
>
> You are using jQuery which comes with it's own AJAX routines - why
> re-invent the wheel?
>
>>| <!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>";
>
> echo "<input class='article' type='text' name='orders[]'><br>";
>
> The name of the element is transmitted on form submit. Because there are
> multiple entries then send the information as an array and handle this
> server-side.
>
>>| }
>>| ?>
>>| </body>
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
multiple dynamic text fields hipa <hipa.invalid@telenet.be> - 2012-03-04 13:00 +0000
Re: multiple dynamic text fields Jeff North <jnorthau@yahoo.com.au> - 2012-03-05 14:33 +1100
Re: multiple dynamic text fields hipa <hipa.invalid@telenet.be> - 2012-03-08 18:14 +0000
Re: multiple dynamic text fields Jeff North <jnorthau@yahoo.com.au> - 2012-03-09 17:38 +1100
Re: multiple dynamic text fields hipa <hipa.invalid@telenet.be> - 2012-03-09 18:46 +0000
Re: multiple dynamic text fields Jeff North <jnorthau@yahoo.com.au> - 2012-03-10 17:19 +1100
Re: multiple dynamic text fields hipa <hipa.invalid@telenet.be> - 2012-03-11 13:55 +0000
Re: multiple dynamic text fields David Mark <dmark.cinsoft@gmail.com> - 2012-03-12 20:16 -0700
Re: multiple dynamic text fields hipa <hipa.invalid@telenet.be> - 2012-03-13 20:08 +0000
Re: multiple dynamic text fields David Mark <dmark.cinsoft@gmail.com> - 2012-03-13 15:36 -0700
Re: multiple dynamic text fields Andrew Poulos <ap_prog@hotmail.com> - 2012-03-14 10:51 +1100
Re: multiple dynamic text fields David Mark <dmark.cinsoft@gmail.com> - 2012-03-13 18:12 -0700
Re: multiple dynamic text fields David Mark <dmark.cinsoft@gmail.com> - 2012-03-13 18:55 -0700
Re: multiple dynamic text fields Andrew Poulos <ap_prog@hotmail.com> - 2012-03-14 15:05 +1100
Re: multiple dynamic text fields David Mark <dmark.cinsoft@gmail.com> - 2012-03-13 21:38 -0700
Re: multiple dynamic text fields David Mark <dmark.cinsoft@gmail.com> - 2012-03-13 21:56 -0700
Re: multiple dynamic text fields David Mark <dmark.cinsoft@gmail.com> - 2012-03-13 22:49 -0700
Re: multiple dynamic text fields Andrew Poulos <ap_prog@hotmail.com> - 2012-03-14 17:05 +1100
Re: multiple dynamic text fields David Mark <dmark.cinsoft@gmail.com> - 2012-03-14 00:23 -0700
Re: multiple dynamic text fields David Mark <dmark.cinsoft@gmail.com> - 2012-03-13 22:06 -0700
Re: multiple dynamic text fields Andrew Poulos <ap_prog@hotmail.com> - 2012-03-14 17:07 +1100
Re: multiple dynamic text fields David Mark <dmark.cinsoft@gmail.com> - 2012-03-14 00:28 -0700
Re: multiple dynamic text fields David Mark <dmark.cinsoft@gmail.com> - 2012-03-13 22:11 -0700
Re: multiple dynamic text fields hipa <hipa.invalid@telenet.be> - 2012-03-14 21:56 +0000
Re: multiple dynamic text fields David Mark <dmark.cinsoft@gmail.com> - 2012-03-14 14:58 -0700
Re: multiple dynamic text fields hipa <hipa.invalid@telenet.be> - 2012-03-15 06:27 +0000
Re: multiple dynamic text fields David Mark <dmark.cinsoft@gmail.com> - 2012-03-14 23:46 -0700
csiph-web