[mv_timeMenu]

Description

Link: [mv_timeMenu]
Author: Marc Vos
Category: Custom Tag
Version: 8.5.x
License: Public Domain
Posted: Jul. 22, 2010
Updated: Aug. 09, 2010
More by this author...
This tag creates time entries for a pop-up menu. You can specify from / to hours and the steps in minutes. You can also pass a value to test against so the 'selected' switch is set on when the value passed matches an entry. The test value cannot contain a colon, i.e. 2300 instead of 23:00.

Parameters

-fromhour integer, optional
-tohour integer, optional
-minutes integer, optional
-selected integer, optional
-firstblank integer, optional If a blank option should be added before 00:00

Sample Usage

[
var('FormField1' = action_param('FormField1');
]

...
...

<select name="FormField1">
[mv_timeMenu(-fromHour=0, -toHour=23, -minutes=10, -selected=$FormField1)]
</select>
						

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
define_tag('mv_timeMenu', -optional='fromhour', -copy, -optional='tohour', -copy, -optional='minutes', -copy, -optional='selected', -copy, -optional='firstblank', -EncodeNone);
// Creates a list of time values inside a <select></select>, which you code & style
// Example: <select name="xyz" class="abc" id="def">[mv_timeMenu(-fromHour=0, -toHour=23, -minutes=10, -selected=$db_value]</select>

local('result' = '');
	if(! local_defined('firstblank'));		local('firstblank' = 0);	else(integer(#firstblank) <= 0);		#firstblank = 0;	/if;
	if(! local_defined('fromhour'));		local('fromhour' = 0);	else(integer(#fromhour) <= 0);		#fromhour = 0;	/if;
	if(! local_defined('tohour'));		local('tohour' = 23);	else(integer(#tohour) <= 0 || integer(#tohour) >= 24);		#tohour = 23;	/if;
	if(! local_defined('minutes'));		local('minutes' = 15);	else(integer(#minutes) <= 0 || integer(#minutes) >= 60);		#minutes = 15;	/if;	
if(#firstblank);	
 #result = '<option value="" ';
 if(local_defined('selected'));
  if(#selected == '');
   #result += ' selected="selected"';
  /if;
 /if;
 #result += '></option>';
/if;

loop(-from=#fromhour, -to=#tohour, -by=1);
 local('z1' = (loop_count < 10 ? '0') + string(loop_count));

 loop(-from=0, -to=59, -by=#minutes);
  local('z2' = (loop_count == 0 ? '00' | loop_count));

  #result += '<option value="' + #z1 + #z2 + '" ';

  if(local_defined('selected'));
   if(#selected != '' && #selected == (#z1 + #z2));
    #result += ' selected="selected"';
   /if;
  /if;

  #result += '>' + #z1 + ':' + #z2 + '</option>';
 /loop;
/loop;

return(#result);
/define_tag;

 

Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net