The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
![]() |
Re-filling form fields of populated dropdown - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: API (https://forums.formtools.org/forumdisplay.php?fid=17) +--- Thread: Re-filling form fields of populated dropdown (/showthread.php?tid=1068) |
Re-filling form fields of populated dropdown - sogreen - Feb 5th, 2011 I just did a clean install of 2.0.4. I tried to use the re-filling form fields using the api tutorial but I couldn't get it to work. I discovered replacing @$fields with @$_POST seemed to do the trick. However, I am now populating the drop-downs with the information in the ft database. It works great and is now very easy to update among all of my forms, but I don't know how to include the refilling form fields script. Can anyone help me with this? I am using the following code: <?php $result = @mysql_query("select option_value,option_name from database.ft_field_options where field_group_id='1'); print "<select name='category'>\n"; while ($row = mysql_fetch_assoc($result)){ $value = $row['option_value']; $name = $row['option_name']; print "<option value=$value>$name</option>\n"; } print "</select>\n"; ?> RE: Re-filling form fields of populated dropdown - Ben - Feb 9th, 2011 Hi sogreen, So just so I understand: the dropdown code that you posted is working okay, you just need it to set the appropriate value in the dropdown? If that's the case, you're almost done. You'll just need to add something like this: PHP Code: <?php .. and replace "$THEVALUE" with whatever variable contains the value for that field. Hope this helps a bit. If I misunderstood, post me back. - Ben RE: Re-filling form fields of populated dropdown - sogreen - Feb 9th, 2011 Thank you so much! That did the trick, it works perfectly. RE: Re-filling form fields of populated dropdown - sogreen - Feb 11th, 2011 Oops. Upon more testing I have found this isn't working the way I would like... Now, when you go to the form it automatically selects that last option in each dropdown field. I want it to have the first row (which is a blank field in the database) to show up. Then when the user selects an option, if the recaptcha is entered incorrectly, the option they selected is still selected until they get redirected to the "success" page. Does this make sense? |