The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
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
$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'];
  
$selected = ($row['option_value'] == $THEVALUE) ? " selected" : ""; 
  print "
<option value=$value{$selected}>$name</option>\n";
}
print "
</select>\n";
?>

.. 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?