Mar 28, 2005 04:20
On my Nightly Numbers System, a manager can "Enter Any Dells Numbers". The default name for a while was the first A name in the company, since you selected it from the employee list. That A name would get accidental entries a lot, so I changed it a year ago so the default name was "Select A Name". The other day I checked the stats for this year and there was 9 entries for Select A Name, so I mentioned it in an email I sent to the company. I get a response from Bruce and Steve saying "Why don't you make it so they have to select a name."
Well the problem with that is I really didn't know a lot of javascript. All of the form validations on my pages were taken from a page builder I used when I created the initial site. So today I did a bit of research and came up with this code, which I thought should have worked.
else if (document.frmMain.fld201RefName1 == "Select A Name")
{
alert('You Must Select A Name!');
return false;
}
I couldn't figure out why that wasn't working. So I added this line:
alert('Hi '+document.frmMain.fld201RefName1+'!');
Which created a popup that said Hi [Object]!
So I started searching around on sites trying different approaches changing the code to try to make it work and during the 3 hour process having 18 Select A Name entries go through. :P This running on my local test database of course.
I found that it doesn't treat Select Option form entries the same way it treats strings. After a lot of trouble I found that adding .value fixed the problem, thus making it:
else if (document.frmMain.fld201RefName1.value == "Select A Name")
Yay for client side validation. So I worked a crazy 110 hours the past 2 weeks because we were totally swamped. I signed up for a schedule working 55 regular pay hours a week. Crazy eh? Maybe I'll finally be able to afford to upgrade my computer, get my bills paid off, and move out of my parents house. But who would be my roommates? I can't wait to see how big my check is Friday. ;)