• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

can i call onload while submitting the form

function setFrieghtQty(tmpId)
{
      
      if(document.getElementById("totalWeight")!=null)
            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;

      roundDecimals(freightQtyObj,3);
      var currentFreightQty      = freightQtyObj.value;

      if(totalAmountObj!=null)
      {
            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
0
chaitu chaitu
Asked:
chaitu chaitu
  • 3
  • 2
1 Solution
 
sajuksCommented:
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">
</form>
0
 
TimYatesCommented:
can't you put:

    onSubmit="yourOnloadMethod()"

into your form tag?
0
 
TimYatesCommented:
hehehe
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
chaitu chaituAuthor Commented:


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
0
 
sajuksCommented:
//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">
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--


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

return true
}
//-->
</SCRIPT>
</HEAD>

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

0
 
TimYatesCommented:
or

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

then

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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now