Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8595921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:33:17+00:00 2026-06-12T00:33:17+00:00

I have a wage calculation form that start from retrieving sum of wage from

  • 0

I have a wage calculation form that start from retrieving sum of wage from database and then, after user add some extra payment in order to calculate Net wage, save them back to database once again.

My problem was my code is only work to save one record at a time. What I need was to be able to save all records at the same time. So could you please help me.

<%
if Rs.eof then 
    response.write "<tr><td colspan=""9"">&nbsp;"
    call displayNotFoundRecord
    response.write "</td></tr>"
Else

    Do while Rs.AbsolutePage = strPageCurrent And Not Rs.EOF
    dim color 

            y = n mod 2
                if y > 0 then
                    color =  "EFF4FA"
                else 
                    color = "ffffff"
                end if                  

    if rs.fields.item("if_social_sec") = "True"  then
        displaytxt = "" 
        soc_sec_v = soc_sec
    else
        displaytxt = "none"
        soc_sec_v = 0
    end if 

    wage_v = rs.fields.item("Total")
    salary_v = rs.fields.item("lb_salary")

    if rs.fields.item("lb_type") = "perunit"  then
        salary_wage = wage_v
        displaytxt_w = "readonly class=""bgdisable""" 
        displaytxt_lb = "readonly class=""bgdisable"""      
    else
        salary_wage = salary_v
        displaytxt_w = ""
        displaytxt_lb = ""      
    end if

if_pm = request.form("if_pm")

pm_pay = rs.fields.item("lb_pmPay") 
    if if_pm <> "" then
        if_pm_v = pm_pay   
        disable_txt_pm = "readonly"     
    else
        if_pm_v = 0 
        disable_txt_pm = "readonly class=""bgdisable""" 
    end if  



%>
<form name="myform2_<%=n%>" action="salary_action.asp" method="POST">
<tr bgcolor="#<%=color%>"> 
<td class="btline difcursor" nowrap  width="7%">&nbsp;<%=rs.fields.item("lb_name")%></td>
<td class="btline center"  nowrap  width="8%"><input type="text" name="working_day" id="working_day" value="<%=rs.fields.item("MaxOfdays")%>" size="7" <%=displaytxt_w%> onFocus="startCalc(this);" onBlur="stopCalc(this);"></td>
<td class="btline "  nowrap width="10%"><input type="text" name="wage" id="wage" value="<%=salary_wage%>"  onFocus="startCalc(this);" onBlur="stopCalc(this);"></td>
<td class="btline center"  nowrap  width="8%"><input type="text" name="OT" id="OT" size="7" value="<%=if_OT_v%>" onFocus="startCalc(this);" onBlur="stopCalc(this);" <%=disabled_ot%>></td>
<td class="btline center" nowrap  width="6%" ><input type="text"  name="OT_rate" id="OT_rate" size="5" value="<%=rs.fields.item("lbOT")%>" <%'=disabled_txt%> readonly class="bgdisable"></td>
<td class="btline center" nowrap  width="6%" ><input type="text" name="OT_amt" id="OT_amt" size="5" value="" <%'=disabled_txt%>  readonly class="bgdisable"></td>
<td class="btline center" nowrap  width="8%"  ><input type="text" name="soc_sec" id="soc_sec" size="7" value="<%=soc_sec_v%>" <%=disable_txt_soc%> onFocus="startCalc(this);" onBlur="stopCalc(this);"></td>
<td class="btline center"  nowrap  width="8%"><input type="text" name="pmPay" id="pmPay" size="7" value="<%=if_pm_v%>" onFocus="startCalc(this);" onBlur="stopCalc(this);" <%'=disable_txt_pm%> readonly class="bgdisable"></td>
<td class="btline" nowrap style="padding-left: 10px" width="8%" ><input type="text" name="ex_pay" id="ex_pay" size="7" onFocus="startCalc(this);" onBlur="stopCalc(this);"></td>
<td class="btline bold " width="10%"><input type="text" name="net_wage" id="net_wage" size="7"  readonly class="bgdisable">
<input type="hidden" name="lb_type" id="lb_type" size="7" value="<%=rs.fields.item("lb_type")%>">
<input type="hidden" name="date_from" id="date_from" size="7" value="<%=date_from_txt%>">
<input type="hidden" name="date_to" id="date_to" size="7" value="<%=date_to_txt%>">
<input type="hidden" name="lb_id" id="lb_id" size="7" value="<%=rs.fields.item("lb_id")%>">
<input type="hidden" value="N" name="edit_salary">
</td>
<td class="btline"><input type="text" name="sar_note"  value="" size="14"></td>
<td class="btline"   > <input type="submit" value="Save1"></td>
</tr>


</form>
<%
        Rs.movenext
        n = n + 1       
    Loop
End if
Rs.close

set Rs=nothing
Call DBConnClose()
%>

<tr>
    <td colspan="12" align="center" style="padding:10px;">
            <input type="submit" value="Save2">
    </td>
</tr>

What I need is to make “Save2” work. But right now only “Save1” that work.

Add (my script) :

<script>
var intervals = {};
function startCalc(sender){ 
  var key = sender.form.name;
  intervals[key] = setInterval(function() {
    calc(key);
  },1);
}
function calc(key){
  var oForm = document.forms[key];

working_day = oForm.working_day.value;

  wage = oForm.wage.value;
  lb_type_v = oForm.lb_type.value;

    if (lb_type_v == "daily")
    {
        wage = wage * working_day;
    }
    else
    {
        wage = wage;
    }

  OT_rate = oForm.OT_rate.value;
  OT = oForm.OT.value; 
      OT_amt = OT_rate * OT;
  soc_sec = oForm.soc_sec.value; 
  ex_pay= oForm.ex_pay.value; 
  pmPay = oForm.pmPay.value; 

 net_wage = (wage * 1) + (OT_amt * 1) - (soc_sec * 1) + (ex_pay * 1) + (pmPay * 1);

  oForm.OT_amt.value = OT_amt;
  oForm.net_wage.value = net_wage.toFixed(2);
}

function stopCalc(sender){
  var key = sender.form.name;
  clearInterval(intervals[key]);
}
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:33:18+00:00Added an answer on June 12, 2026 at 12:33 am

    In your loop, you will have to change each input name so that it is unique. You should also change the IDs to make them unique, depending on what you are doing with the IDs, but it’s the name that is important if retrieving all of the records values in one go.

    Easiest way to do this is to add your database ID to the name and ids.

    So, for example, change this line…

    <td class="btline center"  nowrap  width="8%"><input type="text" name="OT" id="OT" size="7" value="<%=if_OT_v%>" onFocus="startCalc(this);" onBlur="stopCalc(this);" <%=disabled_ot%>></td>
    

    …to…

    <td class="btline center"  nowrap  width="8%"><input type="text" name="OT_<%=rs.fields.item("lb_id")%>" id="OT_<%=rs.fields.item("lb_id")%>" size="7" value="<%=if_OT_v%>" onFocus="startCalc(this);" onBlur="stopCalc(this);" <%=disabled_ot%>></td>
    

    (What this does is make each name and id unique by adding an underscore character and the lb_id value from your database.)

    Then in the script where you retrieve your values (you didn’t post this code so I am not sure what it looks like), you will need to open the same recordset and loop through checking for values.

    So before you probably had lines like…

    x = Request(“OT”)

    You would instead do something like this…

    'Open your recordset
    Do while Rs.AbsolutePage = strPageCurrent And Not Rs.EOF
        x = Request("OT_" & Rs("lb_id"))
        '....all your other requests here
        'save to database here etc etc
    Loop
    

    Ok, here is your code modified (have a look at the comments to see where I have moved and removed things)…

    <!--move form tag outside of table-->
    <form name="myform2" action="salary_action.asp" method="POST"> 
    <% 
    if Rs.eof then  
        response.write "<tr><td colspan=""9"">&nbsp;" 
        call displayNotFoundRecord 
        response.write "</td></tr>" 
    Else 
    
        Do while Rs.AbsolutePage = strPageCurrent And Not Rs.EOF 
        dim color  
    
                y = n mod 2 
                    if y > 0 then 
                        color =  "EFF4FA" 
                    else  
                        color = "ffffff" 
                    end if                   
    
        if rs.fields.item("if_social_sec") = "True"  then 
            displaytxt = ""  
            soc_sec_v = soc_sec 
        else 
            displaytxt = "none" 
            soc_sec_v = 0 
        end if  
    
        wage_v = rs.fields.item("Total") 
        salary_v = rs.fields.item("lb_salary") 
    
        if rs.fields.item("lb_type") = "perunit"  then 
            salary_wage = wage_v 
            displaytxt_w = "readonly class=""bgdisable"""  
            displaytxt_lb = "readonly class=""bgdisable"""       
        else 
            salary_wage = salary_v 
            displaytxt_w = "" 
            displaytxt_lb = ""       
        end if 
    
    if_pm = request.form("if_pm") 
    
    pm_pay = rs.fields.item("lb_pmPay")  
        if if_pm <> "" then 
            if_pm_v = pm_pay    
            disable_txt_pm = "readonly"      
        else 
            if_pm_v = 0  
            disable_txt_pm = "readonly class=""bgdisable"""  
        end if   
    
    
    
    %> 
    <!--form tag moved outside of table-->
    <tr bgcolor="#<%=color%>">  
    <td class="btline difcursor" nowrap  width="7%">&nbsp;<%=rs.fields.item("lb_name")%></td> 
    <td class="btline center"  nowrap  width="8%"><input type="text" name="working_day_<%=rs.fields.item("lb_id")%>" id="working_day_<%=rs.fields.item("lb_id")%>" value="<%=rs.fields.item("MaxOfdays")%>" size="7" <%=displaytxt_w%> onFocus="startCalc(<%=rs.fields.item("lb_id")%>);" onBlur="stopCalc(<%=rs.fields.item("lb_id")%>);"></td> 
    <td class="btline "  nowrap width="10%"><input type="text" name="wage_<%=rs.fields.item("lb_id")%>" id="wage_<%=rs.fields.item("lb_id")%>" value="<%=salary_wage%>"  onFocus="startCalc(<%=rs.fields.item("lb_id")%>);" onBlur="stopCalc(<%=rs.fields.item("lb_id")%>);"></td> 
    <td class="btline center"  nowrap  width="8%"><input type="text" name="OT_<%=rs.fields.item("lb_id")%>" id="OT_<%=rs.fields.item("lb_id")%>" size="7" value="<%=if_OT_v%>" onFocus="startCalc(<%=rs.fields.item("lb_id")%>);" onBlur="stopCalc(<%=rs.fields.item("lb_id")%>);" <%=disabled_ot%>></td> 
    <td class="btline center" nowrap  width="6%" ><input type="text"  name="OT_rate_<%=rs.fields.item("lb_id")%>" id="OT_rate_<%=rs.fields.item("lb_id")%>" size="5" value="<%=rs.fields.item("lbOT")%>" <%'=disabled_txt%> readonly class="bgdisable"></td> 
    <td class="btline center" nowrap  width="6%" ><input type="text" name="OT_amt_<%=rs.fields.item("lb_id")%>" id="OT_amt_<%=rs.fields.item("lb_id")%>" size="5" value="" <%'=disabled_txt%>  readonly class="bgdisable"></td> 
    <td class="btline center" nowrap  width="8%"  ><input type="text" name="soc_sec_<%=rs.fields.item("lb_id")%>" id="soc_sec_<%=rs.fields.item("lb_id")%>" size="7" value="<%=soc_sec_v%>" <%=disable_txt_soc%> onFocus="startCalc(<%=rs.fields.item("lb_id")%>);" onBlur="stopCalc(<%=rs.fields.item("lb_id")%>);"></td> 
    <td class="btline center"  nowrap  width="8%"><input type="text" name="pmPay_<%=rs.fields.item("lb_id")%>" id="pmPay_<%=rs.fields.item("lb_id")%>" size="7" value="<%=if_pm_v%>" onFocus="startCalc(<%=rs.fields.item("lb_id")%>);" onBlur="stopCalc(<%=rs.fields.item("lb_id")%>);" <%'=disable_txt_pm%> readonly class="bgdisable"></td> 
    <td class="btline" nowrap style="padding-left: 10px" width="8%" ><input type="text" name="ex_pay_<%=rs.fields.item("lb_id")%>" id="ex_pay_<%=rs.fields.item("lb_id")%>" size="7" onFocus="startCalc(<%=rs.fields.item("lb_id")%>);" onBlur="stopCalc(<%=rs.fields.item("lb_id")%>);"></td> 
    <td class="btline bold " width="10%"><input type="text" name="net_wage_<%=rs.fields.item("lb_id")%>" id="net_wage_<%=rs.fields.item("lb_id")%>" size="7"  readonly class="bgdisable"> 
    <input type="hidden" name="lb_type_<%=rs.fields.item("lb_id")%>" id="lb_type_<%=rs.fields.item("lb_id")%>" size="7" value="<%=rs.fields.item("lb_type")%>"> 
    <input type="hidden" name="date_from_<%=rs.fields.item("lb_id")%>" id="date_from_<%=rs.fields.item("lb_id")%>" size="7" value="<%=date_from_txt%>"> 
    <input type="hidden" name="date_to_<%=rs.fields.item("lb_id")%>" id="date_to_<%=rs.fields.item("lb_id")%>" size="7" value="<%=date_to_txt%>"> 
    <input type="hidden" name="lb_id_<%=rs.fields.item("lb_id")%>" id="lb_id_<%=rs.fields.item("lb_id")%>" size="7" value="<%=rs.fields.item("lb_id")%>"> 
    <input type="hidden" value="N" name="edit_salary_<%=rs.fields.item("lb_id")%>"> 
    </td> 
    <td class="btline"><input type="text" name="sar_note"  value="" size="14"></td> 
    <td class="btline"   > <!--submit button removed--></td> 
    </tr> 
    
    
    <!--form tag removed-->
    <% 
            Rs.movenext 
            n = n + 1        
        Loop 
    End if 
    Rs.close 
    
    set Rs=nothing 
    Call DBConnClose() 
    %> 
    
    <tr> 
        <td colspan="12" align="center" style="padding:10px;"> 
                <input type="submit" value="Save2"> 
        </td> 
    </tr> 
    
    <!--move form tag after end of table-->
    </form> 
    

    …and your JavaScript (I just did it in Notepad so hopefully it works)…

    <script> 
    var intervals = {}; 
    function startCalc(key){  
      intervals[key] = setInterval(function() { 
        calc(key); 
      },1); 
    } 
    function calc(key){ 
     // var oForm = document.forms[key]; 
    
    working_day = document.getElementById("working_day_" + key).value; //oForm.working_day.value; 
    
      wage = document.getElementById("wage_" + key).value; //oForm.wage.value; 
      lb_type_v = document.getElementById("lb_type_" + key).value; //oForm.lb_type.value; 
    
        if (lb_type_v == "daily") 
        { 
            wage = wage * working_day; 
        } 
        else 
        { 
            wage = wage; 
        } 
    
      OT_rate = document.getElementById("OT_rate_" + key).value; //oForm.OT_rate.value; 
      OT = document.getElementById("OT_" + key).value; //oForm.OT.value;  
          OT_amt = OT_rate * OT; 
      soc_sec = document.getElementById("soc_sec_" + key).value; //oForm.soc_sec.value;  
      ex_pay= document.getElementById("ex_pay_" + key).value; //oForm.ex_pay.value;  
      pmPay = document.getElementById("pmPay_" + key).value; //oForm.pmPay.value;  
    
     net_wage = (wage * 1) + (OT_amt * 1) - (soc_sec * 1) + (ex_pay * 1) + (pmPay * 1); 
    
      document.getElementById("OT_amt_" + key).value = OT_amt; //oForm.OT_amt.value = OT_amt; 
      document.getElementById("net_wage_" + key).value = net_wage.toFixed(2); //oForm.net_wage.value = net_wage.toFixed(2); 
    } 
    
    function stopCalc(key){ 
      clearInterval(intervals[key]); 
    } 
    </script> 
    

    You will also need to modify the page that your form submits to. Hopefully you can do this using the instructions I gave above???

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sql table of payroll data that has wage rates and effective
I have a database table like this: wagetable name lowhours highhours wage Default 0
I have created the output for a program that allows a user to input
I want to return the rows in my database that have the attribute in
Have a photography site that I want to prevent image copying from. How can
Have searched the database but need to specifically sum(of hours flown or days off)in
SELECT E.id_employee,E.name,E.age,E.wage,D.name, CASE (SELECT COUNT(*) FROM manages M WHERE M.id_employee=E.id_employee) WHEN 1 THEN 'Chief'
I have a query that fetches employee's name, date, working hours, wage and calculate
I am designing a very small relational database for tracking my salaries from different
Have some code: using (var ctx = new testDataContext()) { var options = new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.