This topic is locked
[SOLVED]

 Default value from query

11/8/2009 2:16:21 PM
PHPRunner General questions
S
Stucco author

I would like to set the default value of a dropdown based on which user is entering the data.
I have many users from many customers. The user table has a customer_id field. There is a customer_id field in the records they enter as well. I would like this dropdown customer_id field to be automatically set when they enter a new record. So I really want the default to be select customer_id from users where id = $user_id;
It would be ok for this field to be a read only instead of a dropdown.
Also there are other dropdowns on the page that are dependent on this dropdown. In other words when you change the customer dropdown it changes other questions to specific options for that customer. I'm guessing this means I will need to somehow call that js function after the dropdown is defaulted.

J
Jane 11/9/2009

Hi,
you can save customer_id from users table in the AfterSuccessfulLogin event:

$_SESSION["customer_id"] = $data["customer_id"];



Then use $_SESSION["customer_id"] as default value on the "Edit as" settings dialog on the Visual Editor tab.