+ Reply to Thread
Results 1 to 4 of 4

Thread: Update on Fly and/or Prompt

  1. #1
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    Update on Fly and/or Prompt

    Hi All,

    Ok, when editing it will be for multiple records...the form looks like below but again for multiple records down...

    Code:
    1Qqty  - 2Qqty  - 3Qqty  - 4Qqty  - TotalQty - Input $ - Master $
    [qty]      [qty]      [qty]   [qty]  [sumqty][input(if master0)][master$-no edit]
    
    Issue: I have a statement if Master$ <> 0 then they can't enter an input$. else they can enter input$. The only thing is...I can't force a user to always have input$, they may or may not. So....right now, I'd like to have a check if TotalQty >0 and Master$ = 0 then check input$, if input$ is 0 then prompt enter amt.

    but in order to look at TotalQty I need javascript to sum on the fly as numbers are entered in 1Q, 2Q, 3Q, 4Q...how should I go about this?

    right now if i edit and enter qty's and master$ is $0 and I don't enter an Input$...then all my calculations stay at $0.
    ....if they enter qty and master is $0 then must something in Input$.
    Last edited by Rebelle; July 24th, 2009 at 02:04 PM.

  2. #2
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    This can be done. I had a javascript that basically did a sum across columns and down rows as numbers were entered. It's really fun (sorry, it was for a previous company, so I don't have it any more).

    - Are your input fields in an HTML table; so it looks like a spreadsheet?
    - If so, name your text boxes so you can locate them by name, such as ID="TB_01_04" would be Row 1 Column 4
    - Create the javascript and execute it as the onblur event for every input text box.
    - In the JS either sum across the row or down the column or both and then set the value of the approprate total text box.

    Clear as mud?
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  3. #3
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    hey w0lffy...

    hope i'm making you catch up to micky

    anyh00t....
    ok, yes i have in table like attachment.

    first 4 fields are inputs for Qtrs...then is a Total Qty across but this only populates after saving right now...then it either see if Master$ (in blue) OR field(input$-if master is $0) and takes that x QtrQty's and then by x TotalQtry. this again, only after save is hit.

    so is it better to go this route, once user inputs qty, onblur the total qty and then check if master$ is $0 and prompt user to input $? just trying to think of the best way or how this should be handled...
    Attached Images

  4. #4
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    Very Pretty;

    After looking at your screen shot, I'm gong to revise how I would do this. Basically, you are wanting to validate the form on submit to ensure that all input$ text boxed have a value greater then 0, and if not, scold the user and not submit the form.

    Create an onSubmit javascript event handler. If you name all your input$ text boxes with the same name, then you can do a document.getElementsByName("input$") to return a collection of the input$ text boxes. Loop through the collection and check the value and if you find an input$ text box without a valid value, take the approriate action and return false to cancel the submit.

    The "appropriate action" could be just about anything. Consider putting a hidden text field right next to each input$ text box with a ! (or some other glyph) as its value. Then, when your loop finds an invalid input$, make the !-glyph unhidden again. The trick part here is finding the !-glyph for the text box in error. If the text box and the !-glyph are in the same <td> node, then you should be able to locate the <td> node using the .parentNode method on the text box. Its a bit of work, but would look slick (and is pretty much now ASP.NET does its validation).

    A little bit less work would be to change the background color of the errant text box to red, or some other gosh offal color.
    Last edited by Wolffy; July 24th, 2009 at 06:11 PM.
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

+ Reply to Thread

Similar Threads

  1. run c# visual 2008 express program in command prompt
    By arloguth in forum .NET Development
    Replies: 2
    Last Post: April 18th, 2009, 11:59 PM
  2. UPDATE sql code??
    By Centurion in forum ASP Development
    Replies: 3
    Last Post: March 26th, 2009, 02:04 PM
  3. update Query
    By nboscaino in forum Microsoft Access
    Replies: 32
    Last Post: August 7th, 2008, 01:31 PM
  4. export to excel function prompt help
    By Rebelle in forum JavaScript Programming
    Replies: 2
    Last Post: April 14th, 2008, 11:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO