JavaScript in report.html for Step 14
<SCRIPT LANGUAGE="JavaScript"> var astrParms ; var astrItems ; var strValue ;
var strInput = window.location.search.substring(1) document.write( "<h3> Results of processing by report.html: </h3>" ) ; <!-- document.write( strInput + "<br>") ; -->
if ( ( strInput != null ) && ( strInput.length > 1 ) ) { <!-- Split the arguments apart from each other --> astrParms = strInput.split( '&' ) ;
<!-- Process name --> astrItems = astrParms[ 0 ].split( '=' ) ; strValue = astrItems[ 1 ] ; strValue = strValue.replace( '+', " " ) ; document.write( "<h4>Name is: </h4>" ) ; if ( strValue.length== 0 ) { document.write( "Missing!" ); } else { document.write( strValue ) ; }
<!-- Process employee id --> astrItems = astrParms[ 1 ].split( '=' ) ; strValue = astrItems[ 1 ] ; strValue = strValue.replace( '+', " " ) ; document.write( "<h4>Employee ID is: </h4>" ) ; if ( strValue.length== 0 ) { document.write( "Missing!" ); } else { document.write( strValue ) ; }
<!-- Process os --> astrItems = astrParms[ 2 ].split( '=' ) ; strValue = replaceChars( astrItems[ 1 ] ) ; document.write( "<h4>User's OS is: </h4>" ) ; document.write( strValue ) ;
<!-- Process report --> astrItems = astrParms[ 3 ].split( '=' ) ; strValue = replaceChars( astrItems[ 1 ] ) ; document.write( "<h4>Text of Problem Report is: </h4>" ) ; if ( strValue.length <= 0 ) { document.write( "Missing!" ); } else { document.write( strValue ) ; } } else { document.write( "Input string was empty!" ) ; }
document.write( "<br><br><hr>" ) ; document.write( "<h3> Now please return to the previous page! </h3>" ) ;
function replaceChars( strInput ) { var strTmp = strInput ; strTmp = replaceCh( strTmp, "+" ) ; strTmp = replaceCh( strTmp, "%0D" ); strTmp = replaceCh( strTmp, "%0A" );
return strTmp ; }
function replaceCh( strInput, strChar ) { var i; var strTmp = strInput ;
for ( i = 0; i < 1024; i++ ) { if ( strTmp.indexOf( strChar ) != -1 ) { strTmp = strTmp.replace( strChar, " " ) ; } else { break; } } return strTmp ; }
</SCRIPT>