Wednesday, July 23, 2008

focusing in on a field that's empty with javascript

There seems to be a weirdness when leaving a field that's empty and trying to get the browser to focus back on it. It does it momentarily, but then decides to go back. This script will force the cursor back and focus on the offending field after .1 seconds of leaving it.


<script>
var myInput = '';
function checkMe(obj) {
if(obj.value == '') {
myInput = obj;
myInput.style.background = 'yellow';
myInput.setAttribute('title','This is a required field and blah blah blah');
window.setTimeout('myInput.focus()',100);
}
}
</script>
<input id="foo1" name="foo1" value="init" onchange="checkMe(this);">

<input id="foo2" name="foo2" value="check" onchange="checkMe(this);">

<input id="foo3" name="foo3" value="last" onchange="checkMe(this);">

Friday, July 11, 2008

MS-DOS stuff, tips, notes, etc

Ok, this is really old school to be working in DOS, but just in case I ever need it again...
@echo off 

: PARAMETER PASSING EXERCISES
: TO RUN:
: pass_param.bat "C:\Temp\dos_test.bat"

:http://windowsitpro.com/article/articleid/13443/how-do-i-pass-parameters-to-a-batch-file.html
:When you call a batch file, you can enter data after the command that the batch file 
:refers to as %1, %2, etc. For example, in the batch file hello.bat, the following command

:clear the screen
cls

:http://talk.bmc.com/blogs/blog-gentle/anne-gentle/dos-timestamp-tips/view?searchterm=batch
:create variable to hold yyyymmdd info by using substring function
set yyyymmdd=%date:~10,4%%date:~4,2%%date:~7,2%

:clear current log and start with the following line (single >)
echo %date% %time% Starting script > %log%

:set the file log with the same name as this bat file
set log=%~n0.%yyyymmdd%.log
echo %date% %time% CREATED LOG FILE: %~n0.%yyyymmdd%.log >> %log%

echo.
echo %date% %time% CURRENT FILE RUNNING: %~nx0
echo %date% %time% CURRENT FILE RUNNING: %~nx0 >> %log%
echo.

:All the parameters in action
@echo off
echo %date% %time% passed in parameter %1
echo %date% %time% fully qualified name %~f1
echo %date% %time% drive %~d1
echo %date% %time% path %~p1
echo %date% %time% filename %~n1
echo %date% %time% file extension %~x1
echo %date% %time% short filename %~sn1
echo %date% %time% short file extension %~sx1
echo %date% %time% drive and directory %~dp1
echo %date% %time% filename and extension %~nx1


REM Prompt the user for something...
set /P myvar=Would you like to add something? 

echo.
echo Thanks!
echo.
echo You entered %myvar% 
echo.
echo %date% %time% %myvar% >> %log%