can i call onload while submitting the form

Posted on 2004-11-18
Last Modified: 2010-04-01
function setFrieghtQty(tmpId)
            totalWeight =document.getElementById("totalWeight").value;

      var freightAmount            = document.getElementById("billedAmount1").value;
      var totalAmountObj            = document.getElementById("billedAmount"+tmpId);
      var freightQtyObj            = document.getElementById("freightQty"+tmpId);
      var conversionObj            = document.getElementById("conversionFactor"+tmpId).value;

      var currentFreightQty      = freightQtyObj.value;

            else if(tmpRateBasis.value =="KG")
                  currentFreightQty      = totalWeight;      
                  totalAmountObj.value      = tmpRatePerUnit*conversionObj*currentFreightQty;

      in our jsp when i click refresh in the body onLoad i will call one javascript function and inturn will call setFrieghtQty(tmpId)

      when i click refresh ,values cumulating here and final result is displaying correctly

      but when i submit i want to call body onload function before submitting the form
Question by:chaitu chaitu
    LVL 33

    Expert Comment

    In your submit you need to call the function again explicitly by giving the name
    . i presume that yiu are submitting a form?
    <form name ="frm" method =post onsubmit = "callfunc()">
    <input type = "Submit">
    LVL 35

    Expert Comment

    can't you put:


    into your form tag?
    LVL 35

    Expert Comment

    LVL 20

    Author Comment

    by:chaitu chaitu

    when i click Enter button ;

    in the form i will call

    <form name="frm" onSubmit=validateForm()>

    my enter button like this
    <input type="submit" name="Submit" id="Submit"  value="ENTER" class='input'   onClick="setAction('ENT')">

    in the validateForm() function i want value of Submit button i.e ENTER;

    how can i achive this
    LVL 33

    Accepted Solution

    //something like this, i presume you just want the value of the button ?
    //what does setaction('ent') do ?

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <SCRIPT LANGUAGE="JavaScript">

    function validateForm()
     var submitValue = document.frm.Submit.value;
             alert( submitValue )

    return true

    <form name="frm" onSubmit="return validateForm()">
    <input type= "submit" name="Submit" id="Submit"  value="ENTER" >

    LVL 35

    Expert Comment


      <input type="submit" name="Submit" id="SubmitButton"  value="ENTER" class='input'   onClick="setAction('ENT')">


     var submitValue = document.getElementById( 'SubmitButton' ).value ;

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
    Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video discusses moving either the default database or any database to a new volume.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now