Okay, I am building a page right now that is for creating a project between a series and a creator. The form works this way: The form has a name textfield, and an ID textfield for both the series and creator. If you input the two IDs it will create the project immediately and that's that; but if you don't know the ID, you can input the name instead.
However, if you input the name, there might be several creators or series with those names, so the form output should instead show a select list with the available ones that have a name similar to that... and then after selecting one in the list you can submit again and create the project.
But, here comes to problem that keeps deluding me and driving me crazy. If I want to replace the ID input field with the select list instead it might look like this (with some pseudo code):
$form['add']['seriesname'] = array('#type'=>'textfield' [...]);
if( 'seriesname' has been submitted and the search for the title gave hits ) {
$form['add']['seriesid'] = array('#type'=>'select', '#options'=>$options [...]);
}
else {
$form['add']['seriesid'] = array('#type'=>'textfield' [...]);
}