creating dependent drop down list in zend form - zend-form

does one have any idea how i can create dependent drop downs (Select) in Zend Form.
i.e two drop downs, country and city. city is only populated when country is chosen.
thanks

In zend element (country) you have to add a attribute
'onchange' => 'fillCityBox(this.value)'
This function (fillCityBox) fills the city dropdown by using ajax.

Related

Microsoft Access - Combo Box - cannot add record, join key of table is not in recordset

No matter how many tutorial, guides, or example I try to learn from; I can't seem to figure out how to make mine work. Its almost like a hit and miss when it comes to it. I got it working on some forms but I can't seem to get it working on others. Is there a trick to getting a combo box working; That I am missing?!
for example in my vendor form.
frm_vendor
tbl_vendor -> tbl_address -> tbl_addressType
PK vendorID PK addressID PK addressTypeID
FK addressID FK addressTypeID
I am able to create a combo box which allows you to select the addressTypeID <- no problem
control source = addressTypeID
row source =SELECT [tbl_addressType].[addressTypeID], [tbl_addressType].[addressType] FROM tbl_addressType;
row source type = Query/Table
bound to column = 1
limit to list = 1
not editable
But on this new form, I can't see to get it working.
control source = addressTypeID seems to be invalid and gives me a warning.
When you create a form base off a query. Should I be including every PK / FK in this query even thought I wont be displaying it, so the form can understand the links?
Basically yes, if you need to display data through a combobox, you will need to bind that combobox to some data from the query, so that when the form is open on a particular record, it can set the value of the combobox (here, addressTypeID), which in turn will display the value you want from another table (in this case, tbl_addressType.addressType).
In tis particular case, what you are trying to achieve is actually not very clear and that may be one of the reasons you can't get what you want: if you can't define the problem completely, then you can't find a solution.
What is it you need to show exactly?
You list 3 different tables that have some related information, but it's not clear what is the role of tbl_addressType in this.
Maybe if you had a screenshot of the form it may help?
One point regarding your database naming convention: I think the fact that your PK and FK are named the same is part of the confusion.
If you were to adopt something like this, it may make things a bit clearer:
Vendor -> Address -> AddressType
PK ID PK ID PK ID
FK AddressID FK AddressTypeID
.. VendorName .. AddressTitle
All Primary keys are named ID. Foreign keys follow the convention ForeignTableName+ID.
This makes the relationships unambiguous.
Now, your Vendor table is bound to a form:
frmVendor.RecordSource = SELECT ID, AddressID, VendorName FROM Vendor
So now, let's say we want to display the Vendor's AddressTitle and let the user change the Vendor's address to another one by selecting it from the combobox: add a combobox to the frmVendor, name it cbAddress:
cbAddress.ControlSource = AddressID
cbAddress.RowSource = SELECT ID, AddressTitle FROM Address
cbAddress.RowSourceType = Table/Query
cbAddress.BoundColumn = 1 ' Address.ID is bound to Vendor.AddressID
cbAddress.ColumnCount = 2 ' Two columns: ID and AddressTitle
cbAddress.ColumnWidths = 0;3 ' Width 0 for the ID column will hide it
And you are set.
When your form displays a Vendor record, the combobox will also display the corresponding Address' Title.
If your frmVendor.RecordsetType is Dynaset, then if the user selects another address from the combobox the Vendor.AddressID will be updated to the selected Address.ID.
Now, I still have no idea what you want to do with the AddressType table.
The RowSource for the combo box determines where the data comes from to fill the list with values, this list can be from anywhere in the database.
The ControlSource is the bit that maps the combo box selected value to the query that the form is bound to, i.e. the name in the ControlSource needs to be a field that exists in the RecordSource for the form.
So, in your new form, you need to make sure the query you have based the form on has got a field called addressTypeID.
I agree with #Rikalous
you need to make sure the query you have based the form on has got a field called addressTypeID
Hope this link can help:
Microsoft Access cannot add records join key of table not in recordset

Implementing dropdown menu in phpMyAdmin

I'm learning databases, I have a question:
Is it possible to create a drop down menu in SQL?
for example: Create a drop down menu for Gender, so a user can select either Male or Female?
Many Thanks
If you use MySQL ENUM data types as your table column data type, then phpMyAdmin will present the option values to you as a drop-down selector.
Adding an ENUM column:
Inserting a row:

how to add items to combo box in lightswitch

I'm new to lightswitch and i searched lot, but couldn't find proper solution for this simple question. I need to add items to combo box, based on user selection. ( not from existing table)
For example if user select country ,following towns must add to combo box.
USA - Texas, New York etc
UK - London , Surrey
How can i do this? i'm using vb.net as my back end. i found this article How to create an unbound combobox as useful one. but couldn't able work according to my scenario.
what is the way to add items to combo box?
In Lightswitch, if you want to have a dynamic set of data bound to a control, that data must be in a table. You then need to create a query that filters the data in that table based on the user's selection and bind your control to that query.
Here is a pair of articles that describes implementing a situation that is similar to yours:
Nested AutoCompleteBox for data entry
Nested AutoCompleteBox for data entry Part 2
We can't directly assign our own values to combo box. we have to use either data table ( as mentioned by embedded.kyle ) or we have to create custom control to assign values.
i have used custom User Control for above scenario. detail step that i followed can be found in following Link
Adding a record that doesn't already exist in a bound table is a very common scenario. Unfortunately, there's no out-of-the-box way to do this in LightSwitch, you simply have to write code to achieve it, like in this blog post.
Add non existent records using AutoCompleteBox
Or, of course as was also suggested, you could create a custom control to do the job.

SL5 ComponentOne C1FlexGrid dropdowns dynamic filtering

I am using SL5 based ComponentOne's C1FlexGrid and binding data to the control at runtime. For two columns, I am populating lookup data as dropdowns in the first and second column of the control. In the first column, I am binding company information and in the second column, I am binding department information by default. There is a 1-N relation between Company and Department entities in my model (that is, for every company, there are N no of departments associated to it).
In edit mode, I want to filter out departments in the second column of the control for the selected company in the first column (that is, when I select "company 1" in the dropdown, I want to bind only those departments associated to company 1 in the second dropdown). Is
this achievable?
I have achieved this by following the suggestion mentioned in the forum post Different drop down list/combo box in the same column? .

Access multi selection list box as a criteria to INSERT, UPDATE OR DELETE records from a table

For a database with this schema (a product may belong to one or more categories):
Item_category(product, category_name)
Category(category_name)
Will it be possible for me to build a multi-selection list box (List box data source from the Category relation) using an Access form and then highlighting the categories that the product belongs to (by querying the Item_category table), and at the same time letting users select new categories or deselect highlighted categories so that when an "Update" button is pressed, VBA code will automatically determine either INSERT, UPDATE or DELETE queries are needed to update the Item_category table?
How can I do that? Thanks!
I've generally done this type of interface using a form which looks very much like the "Which fields do you want on your form?" in the Form Wizard. Where you have the Table/Query list of Available Fields in the table in the listbox on the left hand side and the Selected Fields in the listbox on the right hand side. Along with the move left and right command buttons in the middle. The users quite like this interface.
Added: Note that the left hand listbox contains all the category records which aren't present in the products category table. So a category would be present in one or the other listbox but never both.
You very likely will want to use the Multi Select property of the listbox. If you hit the help on that field in the property sheet it should lead you to a page which mentions the ItemsSelected collection. Visit that page for sample code on how to read all the items selected by the user. Or visit http://msdn.microsoft.com/en-us/library/aa196172%28v=office.11%29.aspx.