Results 1 to 13 of 13
  1. #1
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123

    Unanswered: calculation on popup pass to another

    I have a project that requires calculations be done before before submitting the results to a database. The ones entering the data are mostly limited in computer skills and very suceptable to making errors. (I am a programmer that is limited in programming skills and suceptable to creating bugs that require additional work to kill). The calculations would require that I recall a closing number which becomes the beginning number for the next record. I know enough vbscript to brute force the results, but I have seen js popups that have a calendar that once you select a date it populates a text box on the "main" page and the same with a calculator that pops up and once you do hit the = sign, it populates a text box on the main page. I think that I could reduce the number of errors by letting the user see what the results look like before submitting the page for data entry. My problem is that while I can sometimes "borrow" and modify js, most of the time I just don't get it.

    I can create the asp that returns the beginning number and once the the desired value is know, I can submit it to be written to the database. What I don't know how to do is pass the variables from the vbscript asp to the js and visa versa.

    Put simply

    vb page
    startValue = rs.beginnig.fields.item("StartNum")
    "txtWarehouseNumber" and "txtEnd" is waiting on value to be passed back to it for product sent to warehouse and then product left on floor at shift change

    js page
    sees startValue and has a text box for entering total number of skids sent to the warehouse (skid has x number of widgets on the skid) and a text box for number of widgets left on floor at end of shift. The user clicks the "Calculate" button and the js page then does the math to net the number that was sent to the warehouse and puts it on the main page "txtWarehouseNumber" and also give it back "txtEnd" for floor inventory.

    Once I have this back, I can submit the vb page and record the records with no problem.

    As I stated, while not great with vb, I can brute force results. I can figure out some js but some of it, I just don't get. I am a visual person and get it better when I see it work. I am trying to figure out the best way to have inexperienced people to enter the data.

    Whew!!
    Thanks in advance for ANY help,
    Lee

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    I think you are over complicating things....

    Why do you need a pop-up page to calculate the values? why not calculate them on the orginal page using js?

    ASP and JS can operate quite happily on the same page....

    What basically it sound like you want is a screen where they can put in the values, click a calculate button which does a client side calculation and then (if the results look like what they want) they can click a save button to save the results to the db.... yes?

  3. #3
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123
    Yes it is but, the page will is kinda busy now as the user is entering data for two production lines (written to a single row) and each line now has two check boxes, two listboxes, and 3 text boxes. Each line of entries is written dynamically based on where in the facility it is. Two of the text boxes and the listboxes are defaulted to the last product type ran and who ran it. The way it is set up now, the user usually has to enter data into one text box (the production box) per line (unless conditions change for that particular shift) and the page defaluts to that box and once the user enters data and hits the enter key it "tabs" to the next text box on the next line. If no other changes are needed they hit the enter again and it sends the page.


    The problem now is that one department only sends out full skids of product instead of what they ran that shift, but each shift gets credit for the widgets they produced. So there are widgets left on partial skids which must be backed out of the next shift's data. This is the calculation I was going to on the pop up.

    My original solution had them enter the production on one page then when they hit calculate, it would send them to the second where they would review the calculation and the other data entries. I just thought that the pop up might look "cleaner" to the user and would stay very similar to the what the other departments look like?

  4. #4
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Okie, you know your screens better then I....

    To do this with a popup you have a few choices... I suspect the best one for you (considering your earlier statments about ot knowing too much javascript) is to write a javascript function that opens a popup window passing a url that contains a querystring that contains all the data you need to do the calculation.

    That way you can do the entire calculation in asp in the popup window.

    So you would have

    page1
    Collects Data
    Submits data to data base (eventually)
    Pops up page2 passing required values in query string (javascript)

    page2
    Pull data from query string
    Performs calculation
    Displays calculation results.

    The handy thing about this method is (I assume) you already have the calculation code in asp for whent he data is saved so you can just reuse it.

    Make sense?

  5. #5
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123
    please excuse my ignorance!!

    yes it makes sense. but how do i pass the querystring to the popup? do i have to "submit" the form on the main page? this is the part that i dont know how to do without submitting the form.

  6. #6
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    okie you include javascript something like this in your page...
    Code:
    function popup(){
       var shipped=document.frmWiggets.txtNumberShipped;
       var hw="HEIGHT=310,WIDTH=550";
       var pos=", resizable=yes, screen.availtop, screen.availleft";
       var myLink ="calc.asp?NumShipped="+shipped;
       if (navigator.appName != "Microsoft Internet Explorer") {
          myWind=window.open(myLink,"","scrollbars=yes,"+hw +pos);
          myWind.focus();
       } else {
          myWind=window.open(myLink,"","scrollbars=yes,"+hw +pos);
       }
    }
    you then have a html button on your page something like this....
    Code:
    <input type="button" value="Calculate" onclick="popup();" name="calculate">
    does that make sense?

  7. #7
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123
    Please dont give up on me. I am trying. I changed my form name, text field, and popup to match what was in the script. the popup comes up fine. when i request the querystring, i get [object]. i am using vb to like this to display the querystring <%=request.querystring("NumShipped") %>. is this right?

  8. #8
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    That sounds/looks right, yes.

  9. #9
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123
    alllrightttt!
    again dont give up on me. when i posted before, i was not passing the value as i was getting [object] instead. i added ".value" to code shipped=document.frmWiggets.txtNumberShipped; and wala i got the request.

    now i have to still figure out how to do the math on the page. i think that i can do this, but how once i have the final number from the popup, how do i on close(); populate the form in the main page (pass the calculation from the popup to the main page) ??

    again thanks for patience and time,
    lee

  10. #10
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123
    whew. i finally got the two pages talking. now i want to do the calculations (the easy part right?). well they are simple calculations. total num on skid A + total num on skid b - beginning num = result.

    here is the js
    var beg1 = document.form1.hdn1.value;
    var beg2 = document.form1.hdn2.value;
    var txt1 = document.form1.txt1.value;
    var txt2 = document.form1.txt2.value;
    var txt3 = document.form1.txt3.value;
    var txt4 = document.form1.txt4.value;
    var txt5 = document.form1.txt5.value;
    var txt6 = document.form1.txt6.value;
    var end1 = txt1 + txt2 - beg1
    var end2 = txt4 + txt5 - beg2
    well instead of adding it is cancaninating the numbers.
    i can change the + operator to * - / and it works.
    what am i doing wrong?

  11. #11
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123
    kept working on it. wrapped the varibles txt1, txt2, etc in parseInt() and it seemed to work

  12. #12
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    how are you doing the return back to the opening page?? are you using window.parent?

    The thought you wanted to do the calculation in asp not js? ah well, any method works I guess....

  13. #13
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123
    i have the two pages on speaking terms by

    opener.document.mainForm.txt1.value = end1;
    opener.document.mainForm.txt2.value = document.form1.txt2.value;
    opener.document.mainForm.txt3.value = document.form1.txt3.value;
    opener.document.mainForm.txt4.value = end2;
    opener.document.mainForm.txt5.value = document.form1.txt5.value;
    opener.document.mainForm.txt6.value = document.form1.txt6.value;

    i had a problem doing the math, but i wrapped in the parseInt() and that worked.

    yes it has been a lot of work but i have learned some.

    i am still going back and forth with which way to go. i will make the final decision tomorrow. if i knew how to loop through the form text boxes in js when the boxes have dynamic names, i will do the calculations in js. if not i will pass the values to the vb asp and do them in vb. i think i could do things better by doing the calculation client side, but i am writing the text boxes dynamically (ie work cell 1 has lines 1 and 2, work cell 2 has lines 3 and 4. the text boxes look like this. txt11 txt12.... txt21, txt22. for line 1 or 2 and col 1 to 3. i will try for a little while tomorrow and then go with what i know best.
    Thanks!!
    Lee

Posting Permissions

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