Re: Resetting drop-downlists in input-fields for texts
| From: | Tor Vidvei | Date: | Wed, 23 Jan 2008 11:32:11 +0000 |
| Subject: | Re: Resetting drop-downlists in input-fields for texts | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-267899@lists.php.net to get a copy of this message | ||
On Mon, 21 Jan 2008 17:23:34 +0100, "Daniel Brown" <parasane@gmail.com> wrote:
Thanks a lot! I have used the method with <form autocomplete="off"> as this method works fine in the browsers I have tested: IE, FireFox and Opera. If a more specific control over the autocomplete is needed, however, I think your method would provide an excellent solution. In my current project: The autocomplete feature is useful as long as the user works with the same set of exercises, but disturbing when they start on a new set of exercises. If an id that identifies the current set of exercises is given with the url like http:/.../exercises.php?id=12345 this id could be used while constructing the field names according to your method. Then autocomplete would work as wanted. I will put in on the ToDo-list! Regards, TorThe only way I can think of that would allow you to do it is todynamically-name the fields in the form. By doing so, AutoComplete won't be able to recognize the fields, and you should be in good shape. In the example I'm sending, keep in mind that input should still be sanitized properly, and it's by no means as a copy-and-paste-for-production script. <? session_start(); if($_POST && isset($_SESSION['target'])) {/*This is just here for demonstration. Do your processing as you'd like with the POST data here. There are two methods shown. Note the use of the curly brackets and square brackets, as well as the order in which they're typed.*//* Method 1: for() for($i=0;$i<count(${$_SESSION['target']});$i++) { echo ${$_SESSION['target']}[$i]."<br />\n"; } *//*Method 2: foreach() Further handling would be needed to make the variables valid, because $0, $1, $2, etc., are not valid variables. Again, this is only for demonstration purposes.*/ foreach(${$_SESSION['target']} as $p => $v) { echo $p.": ".$v."<br />\n"; }} // Define the unique field name for the form, based on Epoch time. $_SESSION['target'] = "field_".time(); // Adding the brackets after the name will print properly // in HTML to designate the POST fields as an array. $html_field = $_SESSION['target']."[]"; ?> <form method="post" action="<?=$_SERVER['PHP_SELF'];?>" />Field 1: <input type="text" name="<?=$html_field;?>" /><br /> Field 2: <input type="text" name="<?=$html_field;?>" /><br /> Field 3: <input type="text" name="<?=$html_field;?>" /><br /> <input type="submit" value="Post Now" /></form>