source-function-F_check_fields_format

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
Overview

Classes

Interfaces

Exceptions

Functions

  1: <?php
  2: //============================================================+
  3: // File name   : tce_functions_form.php
  4: // Begin       : 2001-11-07
  5: // Last Update : 2013-04-02
  6: //
  7: // Description : Functions to handle XHTML Form Fields.
  8: //
  9: // Author: Nicola Asuni
 10: //
 11: // (c) Copyright:
 12: //               Nicola Asuni
 13: //               Tecnick.com LTD
 14: //               www.tecnick.com
 15: //               info@tecnick.com
 16: //
 17: // License:
 18: //    Copyright (C) 2004-2013 Nicola Asuni - Tecnick.com LTD
 19: //    See LICENSE.TXT file for more information.
 20: //============================================================+
 21: 
 22: /**
 23:  * @file
 24:  * Functions to handle XHTML Form Fields.
 25:  * @package com.tecnick.tcexam.shared
 26:  * @author Nicola Asuni
 27:  * @since 2001-11-07
 28:  */
 29: 
 30: /**
 31:  */
 32: 
 33: $formstatus = true; //reset form status
 34: 
 35: // check buttons actions
 36: if (isset($_POST['update'])) {
 37:     $menu_mode = 'update';
 38: } elseif (isset($_POST['delete'])) {
 39:     $menu_mode = 'delete';
 40: } elseif (isset($_POST['forcedelete'])) {
 41:     $menu_mode = 'forcedelete';
 42: } elseif (isset($_POST['cancel'])) {
 43:     $menu_mode = 'cancel';
 44: } elseif (isset($_POST['add'])) {
 45:     $menu_mode = 'add';
 46: } elseif (isset($_POST['clear'])) {
 47:     $menu_mode = 'clear';
 48: } elseif (isset($_POST['upload'])) {
 49:     $menu_mode = 'upload';
 50: } elseif (isset($_POST['addquestion'])) {
 51:     $menu_mode = 'addquestion';
 52: }
 53: if (!isset($menu_mode)) {
 54:     $menu_mode = '';
 55: }
 56: 
 57: /**
 58:  * Returns an array containing form fields.
 59:  * @return array containing form fields
 60:  */
 61: function F_decode_form_fields()
 62: {
 63:     return $_REQUEST;
 64: }
 65: 
 66: /**
 67:  * Check Required Form Fields.<br>
 68:  * Returns a string containing a list of missing fields (comma separated).
 69:  * @param $formfields (string) input array containing form fields
 70:  * @return array containing a list of missing fields (if any)
 71:  */
 72: function F_check_required_fields($formfields)
 73: {
 74:     if (empty($formfields) or !array_key_exists('ff_required', $formfields) or strlen($formfields['ff_required']) <= 0) {
 75:         return false;
 76:     }
 77:     $missing_fields = '';
 78:     $required_fields = explode(',', $formfields['ff_required']);
 79:     $required_fields_labels = explode(',', $formfields['ff_required_labels']); // form fields labels
 80:     for ($i=0; $i<count($required_fields); $i++) { //for each required field
 81:         $fieldname = trim($required_fields[$i]);
 82:         $fieldname = preg_replace('/[^a-z0-9_\[\]]/i', '', $fieldname);
 83:         if (!array_key_exists($fieldname, $formfields) or strlen(trim($formfields[$fieldname])) <= 0) { //if is empty
 84:             if ($required_fields_labels[$i]) { // check if the field has a label
 85:                 $fieldname = $required_fields_labels[$i];
 86:             }
 87:             $missing_fields .= ', '.stripslashes($fieldname);
 88:         }
 89:     }
 90:     if (strlen($missing_fields)>1) {
 91:         $missing_fields = substr($missing_fields, 1); // cuts first comma
 92:     }
 93:     return ($missing_fields);
 94: }
 95: 
 96: /**
 97:  * Check fields format using regular expression comparisons.<br>
 98:  * Returns a string containing a list of wrong fields (comma separated).
 99:  *
100:  * NOTE:
101:  * to check a field create a new hidden field with the same name starting with 'x_'
102:  *
103:  * An example powerful regular expression for email check is:
104:  *  ^([a-zA-Z0-9_\.\-]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$
105:  * @param $formfields (string) input array containing form fields
106:  * @return array containing a list of wrongfields (if any)
107:  */
108: function F_check_fields_format($formfields)
109: {
110:     if (empty($formfields)) {
111:         return '';
112:     }
113:     reset($formfields);
114:     $wrongfields = '';
115:     while (list($key, $value) = each($formfields)) {
116:         if (substr($key, 0, 2) == 'x_') {
117:             $fieldname = substr($key, 2);
118:             $fieldname = preg_replace('/[^a-z0-9_\[\]]/i', '', $fieldname);
119:             if (array_key_exists($fieldname, $formfields) and strlen($formfields[$fieldname]) > 0) { //if is not empty
120:                 if (!preg_match("'".stripslashes($value)."'i", $formfields[$fieldname])) { //check regular expression
121:                     if (isset($formfields['xl_'.$fieldname]) and !empty($formfields['xl_'.$fieldname])) { //check if field has label
122:                         $fieldname = $formfields['xl_'.$fieldname];
123:                     }
124:                     $wrongfields .= ', '.stripslashes($fieldname);
125:                 }
126:             }
127:         }
128:     }
129:     if (strlen($wrongfields) > 1) {
130:         $wrongfields = substr($wrongfields, 2); // cuts first 2 chars
131:     }
132:     return ($wrongfields);
133: }
134: 
135: /**
136:  * Check Form Fields.
137:  * see: F_check_required_fields, F_check_fields_format
138:  * @return false in case of error, true otherwise
139:  */
140: function F_check_form_fields()
141: {
142:     require_once('../config/tce_config.php');
143:     global $l;
144:     $formfields = F_decode_form_fields(); //decode form fields
145:     //check missing fields
146:     if ($missing_fields = F_check_required_fields($formfields)) {
147:         F_print_error('WARNING', $l['m_form_missing_fields'].': '.$missing_fields);
148:         F_stripslashes_formfields();
149:         return false;
150:     }
151:     //check fields format
152:     if ($wrong_fields = F_check_fields_format($formfields)) {
153:         F_print_error('WARNING', $l['m_form_wrong_fields'].': '.$wrong_fields);
154:         F_stripslashes_formfields();
155:         return false;
156:     }
157:     return true;
158: }
159: 
160: /**
161:  * Strip slashes from posted form fields.
162:  */
163: function F_stripslashes_formfields()
164: {
165:     foreach ($_POST as $key => $value) {
166:         if (($key[0] != '_') and (is_string($value))) {
167:             $key = preg_replace('/[^a-z0-9_\[\]]/i', '', $key);
168:             global $$key;
169:             if (!isset($$key)) {
170:                 $$key = stripslashes($value);
171:             }
172:         }
173:     }
174: }
175: 
176: /**
177:  * Returns XHTML code string to display a window close button
178:  * @param $onclick (string) additional javascript code to execute before closing the window.
179:  * @return XHTML code string
180:  */
181: function F_close_button($onclick = '')
182: {
183:     require_once('../config/tce_config.php');
184:     global $l;
185:     $str = '';
186:     $str .= '<div class="row">'.K_NEWLINE;
187:     $str .= '<form action="'.$_SERVER['SCRIPT_NAME'].'" id="closeform">'.K_NEWLINE;
188:     $str .= '<div>'.K_NEWLINE;
189:     $str .= '<input type="button" name="wclose" id="wclose" value="'.$l['w_close'].'" title="'.$l['h_close_window'].'" onclick="'.$onclick.'window.close();" />'.K_NEWLINE;
190:     $str .= '</div>'.K_NEWLINE;
191:     $str .= '</form>'.K_NEWLINE;
192:     $str .= '</div>'.K_NEWLINE;
193:     return $str;
194: }
195: 
196: /**
197:  * Returns XHTML code string to display Form Submit Button.
198:  * @param $name (string) button name
199:  * @param $value (string) label for button
200:  * @param $title (string) button title, default=""
201:  * @return XHTML code string
202:  */
203: function F_submit_button($name, $value, $title = "")
204: {
205:     echo '<input type="submit" name="'.$name.'" id="'.$name.'" value="'.$value.'" title="'.$title.'" />';
206: }
207: 
208: /**
209:  * Print input row form.
210:  * @param $field_name (string) Name of the form field.
211:  * @param $name (string) Label.
212:  * @param $description (string) Label description (tooltip).
213:  * @param $tip (string) Help to be displayed on the right of the input field.
214:  * @param $value (string) Initial value.
215:  * @param $format (string) Regular expression to check the format of the field.
216:  * @param $maxlen (int) Maximum input lenght.
217:  * @param $date (boolean) True if the field is a date input.
218:  * @param $datetime (boolean) True if the field is a date-time input.
219:  * @param $password (boolean) True if the field is a password.
220:  * @param $prefix (string) code to be displayed after label.
221:  * @return string
222:  */
223: function getFormRowTextInput($field_name, $name, $description = '', $tip = '', $value = '', $format = '', $maxlen = 255, $date = false, $datetime = false, $password = false, $prefix = '')
224: {
225:     require_once(dirname(__FILE__).'/../config/tce_config.php');
226:     global $l;
227:     if (strlen($description) == 0) {
228:         $description = $name;
229:     }
230:     $str = ''; // string to return
231:     $button = '';
232:     if ($date) {
233:         $button = '<button name="'.$field_name.'_date_trigger" id="'.$field_name.'_date_trigger" title="'.$l['w_calendar'].'">...</button>';
234:         $jsdate = 'Calendar.setup({inputField: "'.$field_name.'", ifFormat: "%Y-%m-%d", button: "'.$field_name.'_date_trigger"});'.K_NEWLINE;
235:         $format = '^([0-9]{4})([\-])([0-9]{2})([\-])([0-9]{2})$';
236:         $maxlen = 10;
237:         if (strlen($tip) == 0) {
238:             $tip = $l['w_date_format'];
239:         }
240:     } elseif ($datetime) {
241:         $button = '<button name="'.$field_name.'_date_trigger" id="'.$field_name.'_date_trigger" title="'.$l['w_calendar'].'">...</button>';
242:         $jsdate = 'Calendar.setup({inputField: "'.$field_name.'", ifFormat: "%Y-%m-%d %H:%M:%S", showsTime: "true", button: "'.$field_name.'_date_trigger"});'.K_NEWLINE;
243:         $format = '^([0-9]{4})([\-])([0-9]{2})([\-])([0-9]{2})([ ])([0-9]{2})([\:])([0-9]{2})([\:])([0-9]{2})$';
244:         $maxlen = 19;
245:         if (strlen($tip) == 0) {
246:             $tip = $l['w_datetime_format'];
247:         }
248:     }
249:     $str .= '<div class="row">'.K_NEWLINE;
250:     $str .= '<span class="label">'.K_NEWLINE;
251:     $str .= '<label for="'.$field_name.'" title="'.$description.'">'.$name.'</label>'.K_NEWLINE;
252:     if (!empty($prefix)) {
253:         $str .= $prefix;
254:     }
255:     $str .= '</span>'.K_NEWLINE;
256:     $str .= '<span class="formw">'.K_NEWLINE;
257:     $str .= '<input type="';
258:     if ($password) {
259:         $str .= 'password';
260:     } else {
261:         $str .= 'text';
262:     }
263:     $str .= '"';
264:     if ($date or $datetime) {
265:         $str .= ' style="direction:ltr;';
266:         if ($l['a_meta_dir'] == 'rtl') {
267:             $str .= 'text-align:right;';
268:         }
269:         $str .= '"';
270:     }
271:     $str .= ' name="'.$field_name.'" id="'.$field_name.'" value="'.htmlspecialchars($value, ENT_COMPAT, $l['a_meta_charset']).'" size="20" maxlength="'.$maxlen.'" title="'.$description.'" />';
272:     $str .= $button;
273:     if (strlen($tip) > 0) {
274:         $str .= ' <span class="labeldesc">'.$tip.'</span>';
275:     }
276:     if (strlen($format) > 0) {
277:         $str .= '<input type="hidden" name="x_'.$field_name.'" id="x_'.$field_name.'" value="'.$format.'" />'.K_NEWLINE;
278:         $str .= '<input type="hidden" name="xl_'.$field_name.'" id="xl_'.$field_name.'" value="'.$name.'" />'.K_NEWLINE;
279:     }
280:     $str .= '</span>'.K_NEWLINE;
281:     $str .= '</div>'.K_NEWLINE;
282:     if ($date or $datetime) {
283:         $str .= '<script type="text/javascript">'.K_NEWLINE;
284:         $str .= '//<![CDATA['.K_NEWLINE;
285:         $str .= $jsdate;
286:         $str .= '//]]>'.K_NEWLINE;
287:         $str .= '</script>'.K_NEWLINE;
288:     }
289:     return $str;
290: }
291: 
292: /**
293:  * Print text box row form.
294:  * @param $field_name (string) Name of the form field.
295:  * @param $name (string) Label.
296:  * @param $description (string) Label description (tooltip).
297:  * @param $value (string) Initial value.
298:  * @param $disabled (boolean) If true disable the field.
299:  * @param $prefix (string) code to be displayed after label.
300:  * @return string
301:  */
302: function getFormRowTextBox($field_name, $name, $description = '', $value = '', $disabled = false, $prefix = '')
303: {
304:     require_once(dirname(__FILE__).'/../config/tce_config.php');
305:     global $l;
306:     if (strlen($description) == 0) {
307:         $description = $name;
308:     }
309:     $str = ''; // string to return
310:     $str .= '<div class="row">'.K_NEWLINE;
311:     $str .= '<span class="label">'.K_NEWLINE;
312:     $str .= '<label for="'.$field_name.'" title="'.$description.'">'.$name.'</label>'.K_NEWLINE;
313:     if (!empty($prefix)) {
314:         $str .= $prefix;
315:     }
316:     $str .= '</span>'.K_NEWLINE;
317:     $str .= '<span class="formw">'.K_NEWLINE;
318:     $str .= '<textarea cols="50" rows="5" name="'.$field_name.'" id="'.$field_name.'" title="'.$description.'"';
319:     if ($disabled) {
320:         $str .= ' readonly="readonly" class="disabled"';
321:     }
322:     $str .= '>'.htmlspecialchars($value, ENT_NOQUOTES, $l['a_meta_charset']).'</textarea>'.K_NEWLINE;
323:     $str .= '</span>'.K_NEWLINE;
324:     $str .= '</div>'.K_NEWLINE;
325:     return $str;
326: }
327: 
328: /**
329:  * Print select box row form.
330:  * @param $field_name (string) Name of the form field.
331:  * @param $name (string) Label.
332:  * @param $description (string) Label description (tooltip).
333:  * @param $tip (string) Help to be displayed on the right of the input field.
334:  * @param $value (string) Initial value.
335:  * @param $items (array) array of items to print key => value.
336:  * @param $prefix (string) code to be displayed after label.
337:  * @return string
338:  */
339: function getFormRowSelectBox($field_name, $name, $description = '', $tip = '', $value = '', $items = array(), $prefix = '')
340: {
341:     require_once(dirname(__FILE__).'/../config/tce_config.php');
342:     global $l;
343:     if (strlen($description) == 0) {
344:         $description = $name;
345:     }
346:     $str = ''; // string to return
347:     $str .= '<div class="row">'.K_NEWLINE;
348:     $str .= '<span class="label">'.K_NEWLINE;
349:     $str .= '<label for="'.$field_name.'" title="'.$description.'">'.$name.'</label>'.K_NEWLINE;
350:     if (!empty($prefix)) {
351:         $str .= $prefix;
352:     }
353:     $str .= '</span>'.K_NEWLINE;
354:     $str .= '<span class="formw">'.K_NEWLINE;
355:     $str .= '<select name="'.$field_name.'" id="'.$field_name.'" size="0" title="'.$description.'">'.K_NEWLINE;
356:     foreach ($items as $key => $val) {
357:         $str .= '<option value="'.$key.'"';
358:         if ($key == $value) {
359:             $str .= ' selected="selected"';
360:         }
361:         $str .= '>'.$val.'</option>'.K_NEWLINE;
362:     }
363:     $str .= '</select>'.K_NEWLINE;
364:     if (strlen($tip) > 0) {
365:         $str .= ' <span class="labeldesc">'.$tip.'</span>';
366:     }
367:     $str .= '</span>'.K_NEWLINE;
368:     $str .= '</div>'.K_NEWLINE;
369:     return $str;
370: }
371: 
372: /**
373:  * Print check box row form.
374:  * @param $field_name (string) Name of the form field.
375:  * @param $name (string) Label.
376:  * @param $description (string) Label description (tooltip).
377:  * @param $tip (string) Help to be displayed on the right of the input field.
378:  * @param $value (string) Initial value.
379:  * @param $selected (boolean) set to true if selected.
380:  * @param $disabled (boolean) set to true to disable the field
381:  * @param $prefix (string) code to be displayed after label.
382:  * @return string
383:  */
384: function getFormRowCheckBox($field_name, $name, $description = '', $tip = '', $value = '', $selected = false, $disabled = false, $prefix = '')
385: {
386:     require_once(dirname(__FILE__).'/../config/tce_config.php');
387:     global $l;
388:     if (strlen($description) == 0) {
389:         $description = $name;
390:     }
391:     $str = ''; // string to return
392:     $str .= '<div class="row">'.K_NEWLINE;
393:     $str .= '<span class="label">'.K_NEWLINE;
394:     $hidden = '';
395:     if ($disabled) {
396:         // add hidden field to be submitted
397:         $hidden = '<input type="hidden" name="'.$field_name.'" id="'.$field_name.'" value="'.htmlspecialchars($value, ENT_COMPAT, $l['a_meta_charset']).'" />'.K_NEWLINE;
398:         $field_name = 'DISABLED_'.$field_name;
399:     }
400:     $str .= '<label for="'.$field_name.'" title="'.$description.'">'.$name.'</label>'.K_NEWLINE;
401:     if (!empty($prefix)) {
402:         $str .= $prefix;
403:     }
404:     $str .= '</span>'.K_NEWLINE;
405:     $str .= '<span class="formw">'.K_NEWLINE;
406:     $str .= '<input type="checkbox"';
407:     if ($disabled) {
408:         $str .= ' readonly="readonly" class="disabled"';
409:     }
410:     $str .= ' name="'.$field_name.'" id="'.$field_name.'" value="'.$value.'"';
411:     if (F_getBoolean($selected)) {
412:         $str .= ' checked="checked"';
413:     }
414:     $str .= ' title="'.$description.'" />';
415:     $str .= $hidden;
416:     if (strlen($tip) > 0) {
417:         $str .= ' <span class="labeldesc">'.$tip.'</span>';
418:     }
419:     $str .= '</span>'.K_NEWLINE;
420:     $str .= '</div>'.K_NEWLINE;
421:     return $str;
422: }
423: 
424: /**
425:  * Print fixed value row form.
426:  * @param $field_name (string) Name of the form field.
427:  * @param $name (string) Label.
428:  * @param $description (string) Label description (tooltip).
429:  * @param $tip (string) Help to be displayed on the right of the input field.
430:  * @param $value (string) Initial value.
431:  * @param $currency (boolean) if true the value is a curency number.
432:  * @param $prefix (string) code to be displayed after label.
433:  * @return string
434:  */
435: function getFormRowFixedValue($field_name, $name, $description = '', $tip = '', $value = '', $currency = false, $prefix = '')
436: {
437:     require_once(dirname(__FILE__).'/../config/tce_config.php');
438:     global $l;
439:     if (strlen($description) == 0) {
440:         $description = $name;
441:     }
442:     $str = ''; // string to return
443:     $str .= '<div class="row">'.K_NEWLINE;
444:     $str .= '<span class="label">'.K_NEWLINE;
445:     $str .= '<label for="DISABLED_'.$field_name.'" title="'.$description.'">'.$name.'</label>'.K_NEWLINE;
446:     if (!empty($prefix)) {
447:         $str .= $prefix;
448:     }
449:     $str .= '</span>'.K_NEWLINE;
450:     $str .= '<span class="formw">'.K_NEWLINE;
451:     $str .= '<input type="text" readonly="readonly" name="DISABLED_'.$field_name.'" id="DISABLED_'.$field_name.'"';
452:     if ($currency) {
453:         $value = F_formatCurrency($value, 2);
454:         $str .= ' class="disablednum"';
455:     } else {
456:         $str .= ' class="disabled"';
457:     }
458:     $size = 20; // default value
459:     if (strlen($value) > 20) {
460:         $size = 40;
461:     }
462:     $str .= ' value="'.htmlspecialchars($value, ENT_COMPAT, $l['a_meta_charset']).'" size="'.$size.'" maxlength="255" title="'.$description.'" />';
463:     if (strlen($tip) > 0) {
464:         $str .= ' <span class="labeldesc">'.$tip.'</span>';
465:     }
466:     // add hidden field to be submitted
467:     $str .= '<input type="hidden" name="'.$field_name.'" id="'.$field_name.'" value="'.htmlspecialchars($value, ENT_COMPAT, $l['a_meta_charset']).'" />'.K_NEWLINE;
468:     $str .= '</span>'.K_NEWLINE;
469:     $str .= '</div>'.K_NEWLINE;
470:     return $str;
471: }
472: 
473: /**
474:  * Print empty form row.
475:  * @return string
476:  */
477: function getFormSmallVertSpace()
478: {
479:     $str = '<div class="row">&nbsp;</div>'.K_NEWLINE;
480:     return $str;
481: }
482: 
483: /**
484:  * Print empty form row.
485:  * @return string
486:  */
487: function getFormSmallDivSpace()
488: {
489:     $str = '<div style="clear:both;height:1px;font-size:1px;">&nbsp;</div>'.K_NEWLINE;
490:     return $str;
491: }
492: 
493: /**
494:  * Print empty form row.
495:  * @return string
496:  */
497: function getFormRowVertSpace()
498: {
499:     $str = '<div class="row" style="margin-bottom:5px;"><hr class="dashed"/></div>'.K_NEWLINE;
500:     return $str;
501: }
502: 
503: /**
504:  * Print form row with title.
505:  * @param $title (string) Title to be printed.
506:  * @return string
507:  */
508: function getFormRowVertDiv($title = '')
509: {
510:     $str = '<div class="row"><hr class="dashed"/></div><div class="row"><div style="color:#666666;text-align:center;">'.$title.'</div></div>'.K_NEWLINE;
511:     return $str;
512: }
513: 
514: /**
515:  * Print form row with submit button when noscript is active.
516:  * @param $name (string) Name of the input form field.
517:  * @return string
518:  */
519: function getFormNoscriptSelect($name = 'selectrecord')
520: {
521:     require_once(dirname(__FILE__).'/../config/tce_config.php');
522:     global $l;
523:     $str = '<noscript>'.K_NEWLINE;
524:     $str .= '<div class="row">'.K_NEWLINE;
525:     $str .= '<span class="label">&nbsp;</span>'.K_NEWLINE;
526:     $str .= '<span class="formw">'.K_NEWLINE;
527:     $str .= '<input type="submit" name="'.$name.'" id="'.$name.'" value="'.$l['w_select'].'" />'.K_NEWLINE;
528:     $str .= '</span>'.K_NEWLINE;
529:     $str .= '</div>'.K_NEWLINE;
530:     $str .= '</noscript>'.K_NEWLINE;
531:     return $str;
532: }
533: 
534: /**
535:  * Print form row with label and description
536:  * @param $name (string) Label.
537:  * @param $description (string) Label description (tooltip).
538:  * @param $value (string) Initial value.
539:  * @return string
540:  */
541: function getFormDescriptionLine($name, $description = '', $value = '')
542: {
543:     if (strlen($description) == 0) {
544:         $description = $name;
545:     }
546:     $str = '<div class="row">'.K_NEWLINE;
547:     $str .= '<span class="label">'.K_NEWLINE;
548:     $str .= '<span title="'.$description.'">'.$name.'</span>'.K_NEWLINE;
549:     $str .= '</span>'.K_NEWLINE;
550:     $str .= '<span class="formw">'.K_NEWLINE;
551:     $str .= $value.'&nbsp;'.K_NEWLINE;
552:     $str .= '</span>'.K_NEWLINE;
553:     $str .= '</div>'.K_NEWLINE;
554:     return $str;
555: }
556: 
557: /**
558:  * Print input row form to upluad a file.
559:  * @param $field_name (string) Name of the form field.
560:  * @param $field_id (string) ID of the form field.
561:  * @param $name (string) Label.
562:  * @param $description (string) Label description (tooltip).
563:  * @param $onchange (string) Javascript code to execute at onchange event.
564:  * @return string
565:  */
566: function getFormUploadFile($field_name, $field_id, $name, $description = '', $onchange = '')
567: {
568:     if (strlen($description) == 0) {
569:         $description = $name;
570:     }
571:     $str = '<div class="row" id="div'.$field_id.'">'.K_NEWLINE;
572:     $str .= '<span class="label">'.K_NEWLINE;
573:     $str .= '<label for="'.$field_id.'" title="'.$description.'">'.$name.'</label>'.K_NEWLINE;
574:     $str .= '</span>'.K_NEWLINE;
575:     $str .= '<span class="formw">'.K_NEWLINE;
576:     $str .= '<input type="file" name="'.$field_name.'" id="'.$field_id.'" size="20" title="'.$description.'"';
577:     if (!empty($onchange)) {
578:         $str .= ' onchange="'.$onchange.'"';
579:     }
580:     $str .= ' />'.K_NEWLINE;
581:     $str .= '</span>'.K_NEWLINE;
582:     $str .= '&nbsp;'.K_NEWLINE;
583:     $str .= '</div>'.K_NEWLINE;
584:     return $str;
585: }
586: 
587: //============================================================+
588: // END OF FILE
589: //============================================================+
590: 
 

© 2004-2018 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy