republican-creole
Search:  

 
 
   All ForumsHot TopicsGallery






how-to block ads


 
Forums » Tech and Talk » OS and Software » Webmasters and Developers » [Javascript] Submit button not working.
Search Topic:
Uniqs:
148
Share Topic:
RSS topic:
toggle:
flat / full
normal / watch
Posting:
Post a:
Post a:
please tell me why my c++ app doesnt work? »
« [Need Info] Open Source Document Management system  
AuthorAll Replies


ProtusMose
Say hi to your mother for me.
Premium
join:2001-10-03
Bellevue, NE
·Cox HSI

 [Javascript] Submit button not working.

I created a generic page for school that isn't functioning. The assignment has already been turned in, so I'm not asking for anyone to do my homework. I'm just trying to figure out where I went wrong, since apparently I've got a fundamental knowledge gap somewhere in here that I haven't been able to resolve.

The page is at:

»academic1.bellevue.edu/users/BSW···pay.html

I'm having a hard time getting the function to display the text properly. It's saying the results are NaN. I can't tell if I converted it to a string incorrectly or what. It's kicking it back with:

Employee #1 earned: $NaNEmployee #2 earned: $NaNEmployee #3 earned: $NaN

Here's the JS:


Can someone give me at least a hint at where I should have taken that left turn at Albuquerque?

--
Blogsaus "The same crowd that cheers at your triumphant entry will be the ones that crucify you in the end. Consider this: the very thing that is worth dying for will be the very thing they hate you for - Andrew Schwab


cowboyro

join:2000-10-11
Shelton, CT

1 edit
var fieldValue=document.getElementById('fieldId').value
document.getElementById() will return the element not the value of the element.


ProtusMose
Say hi to your mother for me.
Premium
join:2001-10-03
Bellevue, NE
·Cox HSI

said by cowboyro See Profile :

var fieldValue=document.getElementById('fieldId').value :p
document.getElementById() will return the element not the value of the element.
Thanks for the clarification. That's how I had it originally, but because I misspelled the script name in the html (:O) it wasn't doing anything and I changed it.

I changed it back to:


Now it looks like there is some kind of error in the logic of the write function.

"Employee #1 earned: $0Employee #2 earned: $0Employee #3 earned: $0"
--
Blogsaus "The same crowd that cheers at your triumphant entry will be the ones that crucify you in the end. Consider this: the very thing that is worth dying for will be the very thing they hate you for - Andrew Schwab


JAAulde
yum yum yum yum yum
Premium,MVM
join:2001-05-09
Hagerstown, MD


1 edit
reply to ProtusMose
Besides what cowboyro See Profile pointed out, which is definitely correct, there are some issues:
1) Do not cheat on line breaks, curly braces, semicolons, etc. It can confuse you or people who read your code, and can cause the parser to do things you're not expecting.
2) Don't try to do so much in one step/line. Break things up for your own readability--mistakes will be a lot easier to find.

Those things in mind, I modified your code to do the following:
http://pastie.textmate.org/private/3opk2lrb3ys92qpbyyocpw

This code works as expected for me.

Some issues I did not correct, but should be noted
1) Many concerns are being combined and coupled in one large function. Things should be broken down into separate, modular, flexible methods to take care of separate concerns (data retrieval, validation, calculations, presentation, etc)
2) Your code requires hard changes to add employees, change overtime threshold, etc. After breaking into separate areas of concern, much of this should become "settable" so that you can easily maintain your code. I did partially address this in my changes, but more should be done.
3) You have a whole lot of repetitive logic/calculations. For maintainability and readability, this sort of functionality should be grouped and abstracted so that it is much more easy to work with. Again, I partially addressed that in my edits.

I recognize the above 3 concerns may not be an issue for you in this very small system, but the more you take it into account, the more ready you'll be to continue building on this. You'll also have your head in the right place when a large job comes around.

Edit: moved code to pastie.textmate.org because the code formatter here is so inflexible

--
No eat apple, eat cookie. Apple spoil dinner.

My Development Sandbox | LinkedIn Profile
-
Forums » Tech and Talk » OS and Software » Webmasters and Developersplease tell me why my c++ app doesnt work? »
« [Need Info] Open Source Document Management system  


Monday, 30-Nov 00:36:06 Terms of Use | Privacy Policy | Hosting by www.nac.net - DSL,Hosting & Co-lo | feedback | contact
over 10 years online! © 1999-2009 dslreports.com.republican-creole
page compression OFF
Most commented news this week
· [124] Time Warner Cable Fires Broadside At Broadcasters
· [112] New AT&T Ad Campaign Hits Back At Verizon
· [96] Apple Joins AT&T Verizon Snark Fest
· [87] New Bill Takes Aim At Higher Verizon ETFs
· [81] Weekend Open Thread
· [80] TiVo Sees Record Customer Losses
· [79] Verizon CEO: Hulu Will Be Dead Soon
· [69] In-Flight Internet Headed For Bumpy Landing?
· [63] Thanksgiving Open Thread
· [41] ICANN Slams DNS Redirection
Most people now reading
· Are GPS's better today? [General Questions]
· Is Easynews down? [Filesharing Software]
· Windows 7 boot manager editing questions [Microsoft Help]
· Malicious website? [Security]
· sysguard2010.com [Security]
· Can not check DSL speed before your order @ Teksavvy [TekSavvy]
· What is the spell hit cap for a lvl 80 full arcane spec mage [World of Warcraft]
· 3.x Feral Druid - Bear Tanking Guide [World of Warcraft]
· [Newsgroups] Newzleech down? [Filesharing Software]