Login Retreive lost passwordRegister
Search

Forum Index / General / Question about SetAutoComplete

[ This topic is solved ]

  Rob Schulp 19 January 09 / 10:37  
Hello,

I found this script (with different column names):

 Quote
 

mysql_select_db($database_MySQL, $MySQL);
$query = "SELECT * FROM 9_projectdata ORDER BY customer";
$sql = mysql_query($query)
or trigger_error(mysql_error(), E_USER_WARNING);

$options = array( 0 => ' -- Selecteer -- ' );
while( $row1 = mysql_fetch_assoc($sql))
{
$options[$row1['id']] = "".$row1['customer']."";
}


It works great. But I also want to save the primary index in another column of the table. When I choose a customer then the corresponding primary key is also to be saved. Can you help me with this?

Thanks in advance!

  Johan Wiegel (Admin) 19 January 09 / 11:01  
I asume you will use this options array to add options to a selectfield?

Take a look at the paramater $useArrayKeyAsValue.
An other option is to use a dbSelectField.

  Rob Schulp 19 January 09 / 13:18  
Yes, that's correct. I need to save the primary key of the choosen customer in a table where the registration is done for the working hours on that specific project.

When I add this line:
$form -> setDynamicOptions( $options, $useArrayKeyAsValue = true );

I see all the array information on top of my screen as soon as I open it. Can you give me a hint how to solve this?

Thank you again.

  Johan Wiegel (Admin) 19 January 09 / 13:25  
Changed at 19 January 09 / 13:26
<?php
$form 
-> setDynamicOptions$optionstrue );
?>

  Rob Schulp 19 January 09 / 14:12  
That doesn't solve it.

This is my form:

$form =& new dbFormHandler();

$form -> dbInfo ( "sbc", "t_projectlog" );
$form -> dbConnect( "ipaddress", "sbc", "support" );
$form -> borderStart( "Invoer projectadministratie" );
$form -> selectField( "Projectleider","projectleider",$projectleader,FH_STRING,false );
$form -> selectField( "Activiteit","activiteit",$activity,FH_STRING,false );
$form -> jsDateField( "Datum activiteit", "datum" );
$form -> timeField( "Starttijd", "starttijd" );
$form -> timeField( "Einddtijd", "eindtijd" );
$form -> textField( "Projectnaam", "projectnaam", FH_STRING, 60, 60, "class=invoer_xxl" );
$form -> SetAutoComplete( "projectnaam", $options );
$form -> setDynamicOptions( $options, true );
$form -> setHelpText( "projectnaam", "Kies een project uit de lijst. Projecten worden gestart door een consultant." );
$form -> textArea( "Addtionele info", "informatie", FH_STRING, 100, 10, "class=invoer_xxl" );
$form -> resetButton();
$form -> submitButton( "Verder" );
$form -> borderStop();

$form -> onSaved ( "doRun" );

$form -> flush();

This seems correct. I'm stucked...

  Johan Wiegel (Admin) 19 January 09 / 14:19  
Changed at 19 January 09 / 14:23
Sorry,

you can't have the keys on a text field

Johan

  Johan Wiegel (Admin) 19 January 09 / 17:54  
Checkout dbSelectfield field. For new projects add an empty text field.

control adding or using exiting project in onsaved funtion

  Rob Schulp 20 January 09 / 13:22  
Hello Johan,

New projects are stored in a separed db. What I want to do with this form is that people can get the customer name and book the hours they worked for that specific customer. For reporting I also need the customer customer ID. Otherwise I can't make a join between de two db.

I like the type ahead function very much. That's why I don't want to use the dbSelect function (for now ;-))

Thanks for now.

  Top


powered by PHP-GLOBE   © 2004 - 2012 FormHandler. All rights reserved.   -   Open source license