Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Asigning value to text box if used  RSS feed

 
David McKittrick
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been working on some code someone gave me on another forum but can't quite get it.

I think I'm having a problem striping out the first letter in the "cd" box.
The boxes will be populated with image codes like: L5487, S5487, D5487 and T6542.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66256
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

This looks a lot more like a JavaScript question than a Servlet one. It's been moved to the HTML forum.

Also, please edit your code to show proper indentation. Unindented code is surprisingly hard to read.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66256
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You say that this code that you got somewhere else. Just at a quick glance I see multitudes of errors. Perhaps it'd be best if you explained what you are trying to accomplish and we can start from scratch?

Also, what's your familiarity with JavaScript?
 
David McKittrick
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, I have a form with 44 text boxes. A customer would enter a catalog number into the boxes. (L5482, D2698, S2188, V5214, ect....)
The catalog number would be saved and used in the submit section, the bottom of the form, a total would be calculated real time as catalog number were filled in.

On the 1st box to be filled out a dollar value of $23 would be assigned. Each extra box filled out would be assigned $6.00

http://www.mckittricks.org/sports1/
(See the "Unaltered images burned to cd") Site is in test mode so nothing is being saved right now.

Thanks in advance.
Dave.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66256
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, it sounds to me like:
  • As each text field is filled in, you want to be notified so you can accumulate a running total.
  • The first text field filled in amasses $23.00
  • Each subsequent field adds $6.00 to the total.
  • If a text field is emptied, the amount should be decremented.


  • Is this correct?

    If so, the approach should be fairly straight-forward:
  • Establish a blur handler on the form
  • In the handler check if the target is a text field, abort if not
  • Iterate through the text fields in the form, counting how many are non-empty
  • If none, set the total to zero and exit.
  • Calculate the total as: 23 + (6 * (count -1))
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!