[State_Select]

Description

Link: [State_Select]
Author: Jeremy Schwartz
Category: Custom Tag
Version: 7.x
License: Public Domain
Posted: Jan. 23, 2006
Updated: Jan. 24, 2006
More by this author...
Creates a select menu of states for use within a form. Takes three optional values: 1. Fieldname: allows you to set the name of the field 2. State: takes a 2 letter state abbr. as the selected item 3. Statename: takes a full statename as the selected item

Parameters

-fieldname string, optional allows you to set the name of the field
-State string, optional takes a 2 letter state abbr. as the selected item
-Statename string, optional takes a full statename as the selected item

Sample Usage

[state_select: -fieldname='your_state', -state='fl']

or 

[state_select: -fieldname='your_state', -statename='florida']
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*====================================================================*\

	Tagname: state_select
	Date: January 23, 2006
	Author: Jeremy Schwartz
	
	Description: Creates a select, pulldown menu of states for use 
		within a form. Takes three optional values:
		
		1. Fieldname: allows you to set the name of the field
		2. State: takes a 2 letter state abbr. as the selected item
		3. Statename: takes a full statename as the selected item
		
	Sample usage: [state_select: -fieldname='your_state', -state='fl']
		
\*====================================================================*/

define_tag: 'state_select', 
			-op='fieldname', 
			-op='state', 
			-op='statename';

	local:'statelist'=
		(array:	'Non US'='Non US',
				'al'='Alabama',
				'ak'='Alaska',
				'az'='Arizona',
				'ar'='Arkansas',
				'ca'='California',
				'co'='Colorado',
				'ct'='Connecticut',
				'de'='Delaware',
				'dc'='District Of Columbia',
				'fl'='Florida',
				'ga'='Georgia',
				'hi'='Hawaii',
				'id'='Idaho',
				'il'='Illinois',
				'in'='Indiana',
				'ia'='Iowa',
				'ks'='Kansas',
				'ky'='Kentucky',
				'la'='Louisiana',
				'me'='Maine',
				'md'='Maryland',
				'ma'='Massachusetts',
				'mi'='Michigan',
				'mn'='Minnesota',
				'ms'='Mississippi',
				'mo'='Missouri',
				'mt'='Montana',
				'ne'='Nebraska',
				'nv'='Nevada',
				'nh'='New Hampshire',
				'nj'='New Jersey',
				'nm'='New Mexico',
				'ny'='New York',
				'nc'='North Carolina',
				'nd'='North Dakota',
				'oh'='Ohio',
				'ok'='Oklahoma',
				'or'='Oregon',
				'pa'='Pennsylvania',
				'ri'='Rhode Island',
				'sc'='South Carolina',
				'sd'='South Dakota',
				'tn'='Tennessee',
				'tx'='Texas',
				'ut'='Utah',
				'vt'='Vermont',
				'va'='Virginia',
				'wa'='Washington',
				'wv'='West Virginia',
				'wi'='Wisconsin',
				'wy'='Wyoming');
				
	local:'html_output'='';
	
	local:'selected'='';
								
	if:!(local:'state')->size;
		local:'state'='';
	/if;
	
	if:!(local:'statename')->size;
		local:'statename'='';
	/if;
	
	if:!(local:'fieldname')->size;
		local:'fieldname'='state';
	/if;
	
	#html_output = '<select name="'+#fieldname+'" size="1">\r';
	
	iterate:#statelist,(local:'i');
		
		#selected = '';
		
		if:#state == (#i->first);
			#selected = ' selected';
		/if;
		
		if:#statename == (#i->second);
			#selected = ' selected';
		/if;
	
		#html_output += '<option value="'+(#i->first)+'"'+#selected+'>'+(#i->second)+'</option>\r';	
		
	/iterate;
	
	#html_output += '</select>\r';
	
	return: #html_output;
	
/define_tag;

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular