<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule">

<channel>
<title>Topic &#x27;[Javascript] Submit button not working.&#x27; in forum &#x27;Webmasters and Developers&#x27; - dslreports.com</title>
<link>http://www.dslreports.com/forum/Javascript-Submit-button-not-working-23300771</link>
<description></description>
<language>en</language>
<pubDate>Sat, 11 Feb 2012 12:31:25 EDT</pubDate>
<lastBuildDate>Sat, 11 Feb 2012 12:31:25 EDT</lastBuildDate>

<item>
<title>Re: [Javascript] Submit button not working.</title>
<link>http://www.dslreports.com/forum/Re-Javascript-Submit-button-not-working-23301392</link>
<description><![CDATA[JAAulde posted : Besides what  cowboyro <A HREF="/useremail/u/217865"><IMG SRC="http://i.dslr.net/bb/profile.gif" ALT="See Profile" BORDER=0 WIDTH=16 HEIGHT=11></A> pointed out, which is definitely correct, there are some issues:<br>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.<br>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.<br><br>Those things in mind, I modified your code to do the following:<br><b><A HREF="http://pastie.textmate.org/private/3opk2lrb3ys92qpbyyocpw">http://pastie.textmate.org/private/3opk2lrb3ys92qpbyyocpw</a></b><br><br>This code works as expected for me.<br><br>Some issues I did not correct, but should be noted<br>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)<br>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.<br>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.<br><br>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.<br><br><b>Edit:</b> moved code to pastie.textmate.org because the code formatter here is so inflexible<br><br><small>--<br>No eat apple, eat cookie. Apple spoil dinner.<br><br><A HREF="http://www.jaaulde.com">My Development Sandbox</a> | <A HREF="http://www.linkedin.com/in/JimAuldridge">LinkedIn Profile</a></small>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-Javascript-Submit-button-not-working-23301392</guid>
<pubDate>Fri, 06 Nov 2009 11:16:18 EDT</pubDate>
</item>

<item>
<title>Re: [Javascript] Submit button not working.</title>
<link>http://www.dslreports.com/forum/Re-Javascript-Submit-button-not-working-23301043</link>
<description><![CDATA[ProtusMose posted : <div class="bquote"><small>said by <a href="/profile/217865" onClick="this.blur(); return popup(event,'/uidpop?ajh=1&uid=217865');">cowboyro</a>:</small><br><br>var fieldValue=document.getElementById('fieldId')<b>.value</b> :p<br>document.getElementById() will return the element not the value of the element.<br> </div>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. <br><br>I changed it back to:<br><br><pre class="brush: text">    var empHours1 = document.getElementById("empHours1");&#012;    var empRate1 = document.getElementById("empRate1");&#012;    var empOver1 = (empHours1 - 40);&#012;    var empHours2 = document.getElementById("empHours2");&#012;    var empRate2 = document.getElementById("empRate2");&#012;    var empOver2 = (empHours2 - 40);&#012;    var empHours3 = document.getElementById("empHours3");&#012;    var empRate3 = document.getElementById("empRate3");&#012;    var empOver3 = (empHours3 - 40);&#012; &#012;</pre><!--end code block--><br>Now it looks like there is some kind of error in the logic of the write function. <br><br>"Employee #1 earned: $0Employee #2 earned: $0Employee #3 earned: $0"<br><small>--<br><A HREF="http://protusmose.com">Blogsaus</a>  "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</small>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-Javascript-Submit-button-not-working-23301043</guid>
<pubDate>Fri, 06 Nov 2009 10:15:15 EDT</pubDate>
</item>

<item>
<title>Re: [Javascript] Submit button not working.</title>
<link>http://www.dslreports.com/forum/Re-Javascript-Submit-button-not-working-23300788</link>
<description><![CDATA[cowboyro posted : var fieldValue=document.getElementById('fieldId')<b>.value</b> :p<br>document.getElementById() will return the element not the value of the element.]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-Javascript-Submit-button-not-working-23300788</guid>
<pubDate>Fri, 06 Nov 2009 09:27:30 EDT</pubDate>
</item>

<item>
<title>[Javascript] Submit button not working.</title>
<link>http://www.dslreports.com/forum/Javascript-Submit-button-not-working-23300771</link>
<description><![CDATA[ProtusMose posted : 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.<br><br>The page is at:<br><br>&raquo;<A HREF="http://academic1.bellevue.edu/users/BSWT032/week3/pay.html" >academic1.bellevue.edu/users/BSW&middot;&middot;&middot;pay.html</A><br><br>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:<br><br>Employee #1 earned: $NaNEmployee #2 earned: $NaNEmployee #3 earned: $NaN<br><br>Here's the JS:<br><br><pre class="brush: text">// pay.js&#012;// Calculating and displaying the pay for employees&#012; &#012;function computePay() {&#012;    var empHours1 = document.getElementById("emp1Hours");&#012;    var empRate1 = document.getElementById("emp1Rate");&#012;    var empOver1 = (empHours1 - 40);&#012;    var empHours2 = document.getElementById("emp2Hours");&#012;    var empRate2 = document.getElementById("emp2Rate");&#012;    var empOver2 = (empHours2 - 40);&#012;    var empHours3 = document.getElementById("emp3Hours");&#012;    var empRate3 = document.getElementById("emp3Rate");&#012;    var empOver3 = (empHours3 - 40);&#012; &#012;    // Calculate and display pay information&#012; &#012;    if (empHours1 &gt; 40) {&#012;        //document.write("Employee #1 earned: $" ((empHours1 - 40) * empRate1 + ((empRate1 * 1.5) * empOver1))&#012;        document.write("Employee #1 earned: $" + (empHours1 - empOver1) * empRate1 + ((empRate1 * 1.5) * empOver1).toString())&#012;      } else&#012;          document.write("Employee #1 earned: $" + empHours1 * empRate1)&#012; &#012;    if (empHours2 &gt; 40) {&#012;          document.write("Employee #2 earned: $" + (empHours2 - empOver2) * empRate2 + ((empRate2 * 1.5) * empOver2).toString())&#012;      } else&#012;          document.write("Employee #2 earned: $" + empHours2 * empRate2)&#012; &#012;    if (empHours3 &gt; 40) {&#012;          document.write("Employee #3 earned: $" + (empHours3 - empOver3) * empRate3 + ((empRate3 * 1.5) * empOver3).toString())&#012;      } else&#012;          document.write("Employee #3 earned: $" + empHours3 * empRate3)&#012;}&#012; &#012;</pre><!--end code block--><br>Can someone give me at least a hint at where I should have taken that left turn at Albuquerque?<br><br><small>--<br><A HREF="http://protusmose.com">Blogsaus</a>  "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</small>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Javascript-Submit-button-not-working-23300771</guid>
<pubDate>Fri, 06 Nov 2009 09:21:45 EDT</pubDate>
</item>

</channel>
</rss>

