/* ************************************************************ * * Scriptname : form.js * Version : 1.0.0 * ************************************************************ * * Copyright © 2003 by Max.nl * ************************************************************ * Description : * * JS for form actions * ************************************************************ * * Date : 10-11-2003 * Author : Erik Verhoofstad * Description : Initial Release * ************************************************************ */ function swapSelected() { for( var i = 0; i < this.elements.length; i++ ) { if( this.elements[i].type == 'checkbox' && !this.elements[i].disabled ) { this.elements[i].checked = !this.elements[i].checked; } } } function selectAll() { for( var i = 0; i < this.elements.length; i++ ) { if( this.elements[i].type == 'checkbox' && !this.elements[i].disabled ) { this.elements[i].checked = true; } } } function doBulkDelete() { if( confirm( 'Hiermee verwijdert u de geslecteerde items.' ) ) { this.sub.value = 'dobulkdelete'; return true; } else { return false; } } /* DRAFT function toggleRowSelect( checkbox, oddOrEven ) { var row = checkbox.parentNode.parentNode; if( checkbox.checked ) { row.className = oddOrEven + ' selected'; } else { row.className = oddOrEven } } function highlightRow( row, checkbox, oddOrEven ) { if( checkbox.checked ) { row.className = oddOrEven + ' selected hover'; } else { row.className = oddOrEven + ' hover'; } } function unHighlightRow( row, checkbox, oddOrEven ) { if( checkbox.checked ) { row.className = oddOrEven + ' selected'; } else { row.className = oddOrEven; } } */ function setListBox( leftList ) { var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null; if( leftList.length == 0 ) { option = document.createElement("option"); option.text = '-------- Geen --------'; option.value = '0'; leftList.add( option, where ); } } function moveOptionLeft( leftList, rightList ) { var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null; // remove '---Geen---' if( leftList.options[0].value == 0 ) { leftList.remove(0); } for( var i = 0; i < rightList.length; i++ ) { if( rightList.options[i].selected && ( rightList.options[i].value != 0 ) ) { option = document.createElement("option"); option.text = rightList.options[i].text; option.value = rightList.options[i].value; option.className = 'newSelected'; leftList.add( option, where ); rightList.remove( i ); i--; } } rightList.selectedIndex = -1; rightList.blur(); } function moveOptionRight( leftList, rightList ) { var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null; for( var i = 0; i < leftList.length; i++ ) { if( leftList.options[i].selected && ( leftList.options[i].value != 0 ) ) { option = document.createElement("option"); option.text = leftList.options[i].text; option.value = leftList.options[i].value; option.className = 'newDeselected'; rightList.add( option, where ); leftList.remove( i ); i--; } } leftList.selectedIndex = -1; leftList.blur(); setListBox( leftList ); } function initSwapBox( leftList, rightList ) { var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null; for( var i=0; i < leftList.length; i++ ) { if( ( !leftList.options[i].selected ) && ( leftList.options[i].value != 0 ) ) { option = document.createElement("option"); option.text = leftList.options[i].text; option.value = leftList.options[i].value; rightList.add( option, where ); leftList.remove( i ); i--; } } leftList.selectedIndex = -1; setListBox( leftList ); } function jumpNext( currentElement, nextElement ) { if( currentElement.value.length == currentElement.maxLength ) { //nextElement.focus(); } } function toggleFileInput( element, hide ) { if( hide ) { element.style.display = 'none'; } else { element.style.display = 'block'; } } function toggleImageInput( element, hide ) { element.disabled = hide; var img = document.getElementById( element.name + '_PREVIEW'); if( hide ) { img.src = '#'; } // else { // img.style.display = 'block'; // } setImage( img ) ; } function showPreview( element ) { var img = document.getElementById( element.name + '_PREVIEW'); img.style.display = 'block'; img.src = 'file://' + element.value; } function setImage( img ) { if( img.src == '#' ) { img.style.display = 'none'; } else { img.style.display = 'block'; } } function setValue( obj, value ) { switch( obj.type ) { //SINGLE SELECT case 'select-one': var opts = obj.options; var l = opts.length; for( var x=0; x