//------------------------------------------------------------------------------ // SmartyFormtool Javascript Library version 1.3 // http://www.phpinsider.com/php/code/SmartyFormtool/ // // Copyright(c) 2004 ispi. All rights reserved. // // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2.1 of the License, or (at // your option) any later version. // // This library is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public // License for more details. //------------------------------------------------------------------------------ ischecked = new Object(); function formtool_checkall(id, field, check_text, uncheck_text) { if (ischecked[id] != "true") { for (i = 0; i < field.length; i++) { field[i].checked = true; } ischecked[id] = "true"; return uncheck_text; } else { for (i = 0; i < field.length; i++) { field[i].checked = false; } ischecked[id] = "false"; return check_text; } } var isselected = new Object(); function formtool_selectall(id, field, select_text, unselect_text) { if (isselected[id] != "true") { for (i = 0; i < field.length; i++) { field.options[i].selected = true; } isselected[id] = "true"; return unselect_text; } else { for (i = 0; i < field.length; i++) { field.options[i].selected = false; } isselected[id] = "false"; return select_text; } } function formtool_moveup(field,save) { for (i = 0; i < field.length; i++) { if(field.options[i].selected == true && i > 0) { var tmplabel = field.options[i-1].label; var tmpval = field.options[i-1].value; var tmptext = field.options[i-1].text; var tmpsel = field.options[i-1].selected; field.options[i-1].label = field.options[i].label; field.options[i-1].value = field.options[i].value; field.options[i-1].text = field.options[i].text; field.options[i-1].selected = field.options[i].selected; field.options[i].label = tmplabel; field.options[i].value = tmpval; field.options[i].text = tmptext; field.options[i].selected = tmpsel; } } formtool_save(field,save); } function formtool_movedown(field,save) { var max = field.length - 1; for (i = max; i >= 0; i--) { if(field.options[i].selected == true && i < max) { var tmplabel = field.options[i+1].label; var tmpval = field.options[i+1].value; var tmptext = field.options[i+1].text; var tmpsel = field.options[i+1].selected; field.options[i+1].label = field.options[i].label; field.options[i+1].value = field.options[i].value; field.options[i+1].text = field.options[i].text; field.options[i+1].selected = field.options[i].selected; field.options[i].label = tmplabel; field.options[i].value = tmpval; field.options[i].text = tmptext; field.options[i].selected = tmpsel; } } formtool_save(field,save); } function formtool_save(choices,storage) { order = new Array(); for(i=0; i maxlen){ if(show_alert) alert('This field cannot exceed ' + maxlen + ' characters.'); textField.value = textField.value.substring(0, maxlen); } else { countField.value = maxlen - textField.value.length; } } }