News

Log In Sponsors
Partner Sites
Online Phone Cards & Cheap Phone Cards & calling cards

Love cooking? Check out healthy recipes at eFoodDepot.com



Re: New in Javascript. Please Help....



Please find the java script part for this file: function handleSave() { if ( true == validateValues( document.formSettings ) ) { disable( document.formSettings.btnSave ); document.formSettings.wardenAction.value = "update.deviceid.range.settings"; document.formSettings.submit(); } } function handleClose() { document.formSettings.wardenAction.value = "close.global.settings"; document.formSettings.submit(); } function handleMissing( id, minVal, maxVal, type ) { document.formSettings.wardenAction.value = "view.lost.tx.settings"; document.formSettings.missingRangeID.value = id; document.formSettings.missingTagMin.value = minVal; document.formSettings.missingTagMax.value = maxVal; document.formSettings.missingTagType.value = type; document.formSettings.submit(); } function testTxCheckNumberType( number, type ) { var iNumber = parseInt( number ); for ( var i = 0; i < document.formSettings.elements.length; i++ ) { if ( document.formSettings.elements[i].type == 'select-one' ) { // The two fields before this are entry fields for min/max TX IDs. // Check that those fit within the range for the type selected // Check that min < max tempMin = document.formSettings.elements[i-2].value; tempMax = document.formSettings.elements[i-1].value; tempType = document.formSettings.elements[i].value; if ( tempMin != '' && tempMax != '' && tempType != '' ) { if ( type == tempType && parseInt( tempMin ) <= iNumber && iNumber <= parseInt( tempMax ) ) return true; } } } return false; } function inovCheck( element ) { if ( 0 != element.value.length ) { if ( true == isNumeric( element.value ) ) { if ( true == testTxCheckNumberType( element.value, '<%=DeviceIDRange.tinov%>' ) ) { return true; } } } return false; } function testTxCheck( element ) { if ( 0 != element.value.length ) { if ( true == isNumeric( element.value ) ) { if ( false == testTxCheckNumberType( element.value, element.name.substring(6) ) ) { alert( element.value + " must be within a specified TX ID Range" ); element.value = ""; element.focus(); return false; } else { if ( true == isdup9450tag ) { alert("The TXID is already assigned"); return false; } else if ( true == isdupQRtag ) { alert("The TXID is already assigned"); return false; } } } else { alert( element.value + " is not a numeric value" ); element.value = ""; element.focus(); return false; } } return true; } function testTxTypeChange( element ) { if ( 0 != element.value.length ) { if ( element.value == "<%=DeviceIDRange.t9450%>" ) { enable( document.formSettings.testTx<%=DeviceIDRange.t9450%> ); } else if ( element.value == "<%=DeviceIDRange.tinov%>" ) { enable( document.formSettings.testTx<%=DeviceIDRange.tinov%> ); } } } function validateValues( what ) { var valid = true; for ( var i = 0; i < what.elements.length && true == valid; i++ ) { myType = what.elements[i].type; myName = what.elements[i].name; if ( myType == 'text' ) { if ( false == (valid = validateFieldEntry( what.elements[i].value )) ) alert( 'Please do not enter non-numeric transmitter IDs.' ); } else if ( myType == 'select-one' ) { // The two fields before this are entry fields for min/max TX IDs. // Check that those fit within the range for the type selected // Check that min < max tempMin = what.elements[i-2].value; tempMax = what.elements[i-1].value; tempType = what.elements[i].value; if (tempType != '' && tempMin != '' && tempMax != '') { if ( '9450' == tempType && false == (valid = (true == in9450Range( tempMin ) && true == in9450Range( tempMax ))) ) { alert( 'Please place all 9450 transmitter IDs in the range of 1 - 240 and 513 - 1023' ); } else if ( 'mom' == tempType && false == (valid = (true == (1 <= tempMin && tempMin <= tempMax && tempMin <= tempMax && tempMax <= 240))) ) { alert( 'Please place all Mother transmitter IDs in the range of 1 - 240' ); } else if ( 'inov' == tempType && false == (valid = (true == inQRRange( tempMin ) && true == inQRRange( tempMax ))) ) { alert( 'Please place all QR IDs in the range 1-65535' ); } else if ( false == (valid = validateMinMax( tempMin, tempMax )) ) { alert( 'Please ensure that minimum transmitter IDs are lower than maximum transmitter IDs.' ); } } else { valid = (tempType == '' && tempMin == '' && tempMax == ''); if ( false == valid ) { alert( 'Please ensure a Min, Max, and Type are configured.' ); } } } } if ( true == valid ) { if ( true == (valid = testTxCheck( document.formSettings.testTx<%=DeviceIDRange.t9450%> )) ) { if ( true == (valid = testTxCheck( document.formSettings.testTx<%=DeviceIDRange.tinov%> )) ) { if ( 0 != document.formSettings.inovMinNew.value.length && 0 != document.formSettings.inovMaxNew.value.length ) { if ( true == (valid = (true == validateMinMax( document.formSettings.inovMinNew.value, document.formSettings.inovMaxNew.value ) && 1 <= parseInt( document.formSettings.inovMinNew.value ) && 65280 >= parseInt( document.formSettings.inovMaxNew.value ))) ) { if ( true == (valid = inovCheck( document.formSettings.inovMinNew )) ) { if ( false == (valid = inovCheck( document.formSettings.inovMaxNew )) ) { alert( 'Please ensure that maximum transmitter ID are lower than or equal to maximum transmitter IDs.' ); } } else alert( 'Please ensure that mimimum transmitter ID are higher than or equal to mimimum transmitter IDs.' ); } else alert( 'Please place all repeater/locator IDs in the range 1-65280 and minimum <= maximum' ); } } } } return valid; } function in9450Range(val) { var iNum = parseInt( val ); return ( (1 <= iNum && iNum <= 240) || (257 <= iNum && iNum <= 1023)); } function inQRRange( val ) { var iNum = parseInt( val ); return 1 <= iNum && iNum <= 65535; } function validateMinMax( minVal, maxVal ) { return parseInt( minVal ) <= parseInt( maxVal ); } function validateFieldEntry( entry ) { return true == isNumeric( entry ) || '' == entry; } function handleMarkDelete( entry ) { if ( 'false' == entry.value ) entry.checked = entry.value = confirm( 'Are you sure you want to delete this range?' ); entry.value = entry.checked; } function do_onLoad() { <% if ( true == is9450 ) { if ( true == testTx9450 ) { %> enable( document.formSettings.testTx<%=DeviceIDRange.t9450%> ); <% } else { %> disable( document.formSettings.testTx<%=DeviceIDRange.t9450%> ); <% } } %> <% if ( true == isInov ) { if ( true == testTxInov ) { %> enable( document.formSettings.testTx<%=DeviceIDRange.tinov%> ); <% } else { %> disable( document.formSettings.testTx<%=DeviceIDRange.tinov%> ); <% } } %> } </script>

Click here to read the whole forum topic