Select of Type State in Contact form 7 - contact-form-7

Am using Contact form 7 and need your help with the following use case:
Select a country from a drop-down list.
Select a country from a drop-down list.
Select state from drop-down list if a specific country’s states are known.
Type in the state if specific country’s states are unknown.
State information is stored in same field, whether selected from drop-down list, or typed in.
Example data:
Country= “C1” “C2” “C3” “C4” “C5”
C1-states= “a” “b” “c” “d”
C2-states= “w” “x” “y” “z”
Expected behavior:
User will select Country from drop-down list.
User will select their appropriate State from drop-down list for C1 and C2
User will type in their State for C3, C4, C5.
Tried using the plugin 'Conditional Fields for Contact Form 7' but it does not seem to work.
Here is the Contact form 7 form I used with conditional field plugin:
<label> Country (required)</label>
[text Country]
[select* Country “C1” “C2” “C3” “C4” “C5”]
[group C1]
<label> State (required)</label>
[select* C1-states “a” “b” “c” “d”]
[/group]
[group C2]
<label> State (required)</label>
[select* C2-states “w” “x” “y” “z”]
[/group]
[group states-1][group states-2]
[/group][/group]
And used the following conditions:
if [Country] equals "C1" then show [C1-states]
if [Country] equals "C2" then show [C2-states]
if [Country] not equals "C1" then show [state-1]
if [Country] not equals "C2" then show [state-2]
In the webpage display, I see two input boxes for the Country with no drop-down box or the state box. Can you help with above? Alternately, is there perhaps some JavaScript I can input in the Contact form 7 function, which may work here? Thanks in advance for your help.

Related

libreoffice base create a list filtered by another list's value

I have a table of provinces and a table of cities with ProvienceID. In a form, I want to create a list of cities filtered by selected value of provience list.
How can I do that?
I can create both lists but Cities list shows all cities from all provinces but i want to show only cities from the province that I have selected in Provinces list.
I have another table "Users" with "CityID" and "ProvinceID" that my form edits it and I need to save selected values of Province and City Lists in it, not only show it in the form.
Create two example tables named "Provinces" and "Cities".
ProvinceID Name
~~~~~~~~~~ ~~~~
0 South
1 North
2 Large Midwest
3 Southeast
4 West
CityID Name ProvinceID
~~~~~~ ~~~~ ~~~~~~~~~~
0 Big City 2
1 Very Big City 2
2 Rural Village 1
3 Mountain Heights 0
4 Coastal Plains 4
5 Metropolis 2
Create a query called "ProvinceNames":
SELECT "Name" AS "Province"
FROM "Provinces"
ORDER BY "Province" ASC
Create a query called "Province of City":
SELECT "Provinces"."Name" AS "Province", "Cities"."Name" AS "City"
FROM "Cities", "Provinces" WHERE "Cities"."ProvinceID" = "Provinces"."ProvinceID"
ORDER BY "Province" ASC, "City" ASC
In the form, create a table control based on the query "ProvinceNames".
Using the Form Navigator (or the Form Wizard), create a subform for query "Province of City".
Right-click on subform and choose Properties. Under Data tab:
Link master fields "Province"
Link slave fields "Province"
Create a table control for the subform as well. Now, the cities shown in the subform control depend on the province selected in the main form control.
EDIT:
Here is an example using a filter table to store the current value of the list box. Create two more tables named "Users" and "FilterCriteria".
UserID Name ProvinceID CityID
~~~~~~ ~~~~~~~ ~~~~~~~~~~ ~~~~~~
0 Person1 1 2
1 Person2 2 0
RecordID ProvinceID CityID
~~~~~~~~ ~~~~~~~~~~ ~~~~~~
the only 0 0
We'll also need two Basic macros which can be stored in the document or in My Macros. Go to Tools -> Macros -> Organize Macros -> LibreOffice Basic.
Sub ReadProvince (oEvent as Object)
forms = ThisComponent.getDrawPage().getForms()
mainForm = forms.getByName("MainForm")
cityForm = forms.getByName("CityForm")
listboxProvince = mainForm.getByName("listboxProvince")
listboxCity = cityForm.getByName("listboxCity")
selectedItemID = listboxProvince.SelectedValue
If IsEmpty(selectedItemID) Then
selectedItemID = 0
End If
conn = mainForm.ActiveConnection
stmt = conn.createStatement()
strSQL = "UPDATE ""FilterCriteria"" SET ""ProvinceID"" = " & selectedItemID & _
"WHERE ""RecordID"" = 'the only'"
stmt.executeUpdate(strSQL)
listboxCity.refresh()
lCityCol = mainForm.findColumn("CityID")
currentCityID = mainForm.getInt(lCityCol)
cityForm.updateInt(cityForm.findColumn("CityID"), currentCityID)
listboxCity.refresh()
End Sub
Sub CityChanged (oEvent as Object)
listboxCity = oEvent.Source.Model
cityForm = listboxCity.getParent()
mainForm = cityForm.getParent().getByName("MainForm")
lCityCol = mainForm.findColumn("CityID")
selectedItemID = listboxCity.SelectedValue
If IsEmpty(selectedItemID) Then
selectedItemID = 0
End If
mainForm.updateInt(lCityCol, selectedItemID)
End Sub
Now we need to set up the form like this. In this example, I used two top-level forms instead of a subform. ProvinceID and CityID text boxes are not required but may be helpful in case something goes wrong.
To start creating this form, use the form wizard to create a new form and add all fields from the Users table.
Now, in the Form Navigator, create a form called "CityForm". Content type is SQL command, and Content is:
SELECT "RecordID", "ProvinceID", "CityID" FROM "FilterCriteria"
WHERE "RecordID" = 'the only'
Next, create the "listboxProvince" list box under MainForm. Data Field is "ProvinceID", and List content is the following Sql.
SELECT "Name", "ProvinceID" FROM "Provinces" ORDER BY "Name" ASC
Finally, create the "listboxCity" list box under CityForm. Data Field is "CityID", and List content is the following Sql.
SELECT "Name", "CityID" FROM "Cities" WHERE "ProvinceID" = (
SELECT "ProvinceID" FROM "FilterCriteria"
WHERE "RecordID" = 'the only')
Macros are linked under the Events tab of each control.
Assign "After record change" of the MainForm to ReadProvince().
Assign "Changed" of listboxProvince to ReadProvince().
Assign "Changed" of listboxCity control to CityChanged().
The result allows us to select the Province to filter the list of Cities. Provinces and Cities that are selected are saved in the Users table.
There is another approach which may be better that I have not had time to explore. Instead of the "FilterCriteria" table, apply a filter to the Cities list. The relevant code in ReadProvince() would look something like this.
cityForm.Filter = "ProvinceID=" & selectedItemID
cityForm.ApplyFilter = True
cityForm.reload()
cityForm.absolute(0)
Whatever approach is taken, a complete solution requires complex macro programming. To make it easier, you may decide to use a simpler solution that is not as powerful. For more information, there is a tutorial at https://forum.openoffice.org/en/forum/viewtopic.php?t=46470.
EDIT 2
A solution that requires fewer queries is at https://ask.libreoffice.org/en/question/143186/how-to-use-user-selected-value-from-combobox1-in-combobox2-select-statement/?answer=143231#post-id-143231. The second list box is based on a list of values instead of an SQL query.

Kentico getting data from multiple choice fields that use SQl causes GetValue to return a number instead of the actual name

I am hoping that there is just a method that I am missing.
Right now i am using {% CurrentDocument.GetValue("marketType").Replace("|", ", ") #%} which works totally fine if I have a list of options. As soon as I switched my field to get data by using :
SELECT 0 AS ItemID, '-Select-' marketType
UNION ALL
SELECT ItemID, marketType FROM BBUS_MarketType
{% CurrentDocument.GetValue("marketType").Replace("|", ", ") #%} started displaying the number of the item instead of the item name itself.
The list of choice has two parts "value,display". Your SELECT statement populate the value with ItemID which is number.
If you want to store the text, then it should be
SELECT '', '-Select-' UNION ALL SELECT marketType, marketType FROM BBUS_MarketType
populate the value with "marketType" instead of ID

Sort based on specific field within a group

I have a report which I need to Group by type but the rows under the group should be sorted based on specific field code. from the below eg. the Reason field needs to be sorted in the order NSL,RWR,PAL,CON order within the grouping.
TYPE DATE NAME CODE
**CEM**
Cem NSL
Cem RWR
Cem PAL
Cem CON
**FUN**
FUN NSL
FUN RWR
FUN PAL
**IP**
IP NSL
IP RWR
IP PAL
The easiest way to do this is to create a formula "Priority" like this:
if CODE="NSL" then 1 else
(if CODE="RWR" then 2 else
(if CODE="PAL" then 3 else
(if CODE="CON" then 4 else 0)) )
and put in into the detail row of you report.
Then goto "Report" menù ->"Record Sort Expert" and sort the detail with your formula "Priority"

Report builder 3.0 cannot figure out how to make the correct expression

I want to show in the report builder a string with the values from different rows that belong to the same id separating them by , for example:
id person= 1 , phone1
id person= 1 , phone2
So in the report builder I can show
person phones
1 phone1 ,phone2
You should be able to accomplish this by creating a group on the "id person" field and in "phones" columns use the expression =join(fields!id_person.value,",")

How to display "All Selected" when parameter (Select All) is selected in SSRS?

Using SSRS 2008 r2...I have a report with a single-value parameter and three multi-value parameters, Class1, Name2 and Name3. I'm hoping for an explanation to one thing that I'm seeing and information on a second thing.
One, on the image, Class1 and Name2 both have the (Select All) parameter selected but Class1 is displaying the concatenated parameter variable list whereas Name2 is showing Null. Why is that? If anything, how can I get Class1 to be similar to Name2 and show Null?
But my desired wish is to have Class1, Name2 and Name3 display the text"All Selected" when the parameter (Select All) is chosen. How can this be achieved?
Thanks.
The datasets referred by Class1, Name2 and Name3 should contain the value All Selected.
To do that you need to add the below codes to the existing datasets:
UNION
SELECT 'ALL SELECTED' as DefaultValue
Then put the default value of all your required parameters to "All Selected".
If you're using a dataset as a source for your multi-select parameter:
"DataSet2" is my source for the multi-select parameter "pmPlant". I check if the number of selected items in your mutli-select parameter match the number of items in your source dataset. If it is, then display your desired text ("All Plants" in this case), if not then then use the "Join" function to combine the selections as a ";" separated list.
=iif(Parameters!pmPlant.Count = CountRows( "DataSet2", ),"All Plants", Join(Parameters!pmPlant.Label,"; "))
This should work:
=IIF(Parameters!ParameterName.Count = COUNT(1, "Dataset Name"), "All", Parameters!ParameterName)