UK counties list for a web form

I need a list of UK counties for a web form that I am creating. I have the list of counties but if I can avoid adding each county into the 'Menu/List individually then this would save me a lot of time. I am using a table based form on my Freeway Pro page and Forms To Go to handle the processing side.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

NB. There are 86 counties in total in the UK


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Do you have php on that page already? I have a generic function you can use to generate a picking list from an array of values if so.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

To make an array out of the county names in the quickest manner, set
them up as a single string, with one comma between each name:

$counties = 'Bedfordshire,Berkshire,Buckinghamshire,Cambridgeshire...';
$counties = explode(',',$counties);
$counties_picker = simpleListBox($counties,'county');

Now all you need to do is put a print statement in your page where you
want the county picker to appear: <php print($counties_picker); ?>

That function call is expecting you to have defined the variable
$county already at the time that you call it if you want the picker to
auto-default to a particular county, or if you would like to set the
value entered by the visitor in the case of an error elsewhere in the
form.

Here’s the function that generates the picker:

/**
  * Converts an array to a picking list with lots of useful features
  * @param array $arrChoices The options for the array
  * @param string $strName The name of the resulting select, also used  
for the ID if no ID is passed
  * @param bool $boolUseKey Whether to use the keys of the array as  
the values or not
  * @param bool $boolListKey Whether to use the keys of the array as  
the label or not
  * @param string $strSelected An alternate to the name of the field  
to use as the auto-selected test value
  * @param string $strId The id of the select, if it isn't the same as  
the name
  * @param string $strClass The className of the select
  * @return string HTML code to describe the select field
  * @author Walter Lee Davis
  */

function simpleListBox ( $arrChoices , $strName, $boolUseKey=false,  
$boolListKey=false, $strSelected='', $strId='', $strClass='')
{
	if(false === $strId) {
		$id = '';
	}else{
		$id = (!empty($strId))? ' id="' . $strId . '"' : ' id="' .  
$strName . '"';
	}
	$class = (!empty($strClass))?' class="' . $strClass . '"':'';
	$out = '<select' . $id . $class . ' name="' . $strName . '" size="1">
		';
	$compare = ($boolUseKey == true)?"key":"val";
	$selected = (isset($strSelected) && !empty($strSelected))? 
$strSelected:$strName;
	//echo $selected;
	global $$selected;
	//echo $$selected;
	foreach($arrChoices as $key=>$val){
		$out .= '    <option label="';
		$out .= ($boolListKey == true)?$key:$val;
		$out .= '" value="';
		$out .= ($boolUseKey == true)?$key:$val;
		$out .=  '"';
		if(${$selected} == ${$compare}) $out .= ' selected="selected"';
		$out .= '>';
		$out .= ($boolListKey == true)?$key:$val;
		$out .= '</option>
			';
	}
	$out .= '</select>';
	return $out;
}

Walter

On Dec 26, 2008, at 5:34 PM, waltd wrote:

Do you have php on that page already? I have a generic function you
can use to generate a picking list from an array of values if so.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Sorry I don’t really know php though it sounds like an easy solution


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Revering to your explanation walt I am always willing to learn and try new things. so in my table would I add some mark up HTML - in this case the print statement where the list would go?

Would the function be added to the page code seperately?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Not being a coder or action writer I thought I would have a go at creating an action for this based on the Country List action - which i have appeared to have managed.

So if you are interested in receiving a copy then let me know.

Walter do you want acopy so that it can be tested on ActionForge

David

info(at)deltadzine.com BTW BoxTrapper is on!


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

The action is online at http://www.deltadzine.net/countylist.html

Where you can also download the version that includes Welsh County names

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Dave, you can create an account for yourself at ActionsForge. It’s entirely self-serve.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You could add all of the code (function and the call to it) in the
before html section of the Page / HTML Markup dialog. Then just the
print statement in the body of your page where you want the picker to
appear.

Walter

On Dec 26, 2008, at 6:58 PM, lfcredbird7 wrote:

Revering to your explanation walt I am always willing to learn and
try new things. so in my table would I add some mark up HTML - in
this case the print statement where the list would go?

Would the function be added to the page code seperately?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

County List action now available at http://actionsforge.com/

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks David

Just what I wanted, too - except where’s “West Midlands”? Am I lost in
no-man’s land? :wink:

Colin

On 27 Dec 2008, at 10:01, DeltaDave wrote:

County List action now available at http://actionsforge.com/

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Delta Dave, I just downloaded the action, this looks like the solution that I am looking for. How would I get this into a drop down list format? Is this possible?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Just resize the height of the box to one entry and it will be a dropdown.

Are the West Midlands a county?

You can edit the list to include it.

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

According to the Association of British Counties http://www.abcounties.co.uk/counties/list.htm

The West Midlands isn’t a County!

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

See http://deltadzine.net/countylist.html

This is the list edited to include your own County

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks David

Only just picked up the thread again - had holiday things to do today!

Strictly you are right about counties in the traditional sense, but
the Royal Mail and the political/local government maps have other
ideas, which means the inclusion of other regions is useful for
address/location purposes.

I was happy to edit the list myself, but thanks for doing it for me -
though I might knock out those few extra words!!! :slight_smile:

Colin

On 27 Dec 2008, at 18:37, DeltaDave wrote:

See http://deltadzine.net/countylist.html

This is the list edited to include your own County

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi David,
Thanks for putting the action together. I’m sure it will come in very
handy.
A couple of suggestions if I may;

  1. You have the list broken down into three sections for England,
    Wales and Scotland but the English counties don’t fall under a
    heading. The fact that they are English counties is implied but not
    stated. Also;
  2. I would suggest using the optiongroup tag to group the county names
    from each of the three areas (see HTML optgroup tag)
    . This not only groups the choices but also ensures the group heading
    (England, Scotland & Wales) cannot be selected by the user.
    Unfortunately optiongroups aren’t supported in Freeway but there is no
    reason why you can’t do this in your action. :slight_smile:
    Regards,
    Tim.

On 27 Dec 2008, at 10:37, DeltaDave wrote:

See http://deltadzine.net/countylist.html
This is the list edited to include your own County
David

FreewayActions.com - Freeware and shareware actions for Freeway
Express & Pro.

Protect your mailto links from being harvested by spambots with Anti
Spam.
Only available at FreewayActions.com

http://www.freewayactions.com


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

another form related question…

i have a series of questions that i want people to answer on my form. i want this in the form of a list with radio buttons/check box for people to select, i also want people to be able to select multiple options from the list but when i publish my results i can only select one item from the list?

how do i set it up so there can be multiple selections on the form?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

There are two different form elements which allow multiple selections:
a checkbox and a select size=N (where N is greater than 1). The former
is very easy to use and familiar. You present a selection of options,
for greater ease on the server size, the usual method is to name them
each the same thing, but use array notation to name the individual
options:

bread[white]
bread[wheat]
bread[sourdough]
bread[challah]
bread[rye]

When this arrives at the server, you will have an array called
$_POST[‘bread’], containing the checked elements, so if someone had
checked off every other option, you would get this array:

bread = Array(
	white=>1,
	sourdough=>1,
	rye=>1
)

If you create a select (picking list) with a size greater than 1 and
the multiple selection option set to true, you can choose more than
one element of the select for submission. This is a very rare use-case
for the select, simply because it’s difficult to un-select anything.
(You have to either control- or command-click, depending on the
browser or platform.) Checkboxes have the distinction of being both
easy to understand and easy to use in this case. It’s really the
preferred technique for this sort of selection.

Walter

On Dec 28, 2008, at 1:16 PM, lfcredbird7 wrote:

another form related question…

how do i set it up so there can be multiple selections on the form?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options