Jump to content

Single Record Update With Javascript


Recommended Posts

Trying to do a single record update with the script below...but it does not seem to be updating...not sure whats wrong

 

<SCRIPT LANGUAGE="JavaScript">
 
function update()
{
var Quantity = document.getElementById("cbParamVirtual1").value;
var Serving = document.getElementById("EditRecordNewDivvyMeal_Servings").value;
var newqty = Serving - Quantity;
document.getElementById("EditRecordNewDivvyMeal_Servings").value = newqty;
 
}
 
document.getElementById("caspioform").onsubmit=update;
 
  if(document.getElementById("caspioform")) {
  document.getElementById("caspioform").style.display = 'none';
  setTimeout('document.forms["caspioform"].submit()',100); } 
 
</SCRIPT>
Link to comment
Share on other sites

I don't know for sure, but it could be that your timeout is too short.

 

I have tried to shorten up the timeout time on my auto-submitted pages and it often submits before the data can be completely updated.

 

<SCRIPT LANGUAGE="JavaScript">

function update()
{
var Quantity = document.getElementById("cbParamVirtual1").value;
var Serving = document.getElementById("EditRecordNewDivvyMeal_Servings").value;
var newqty = Serving - Quantity;
document.getElementById("EditRecordNewDivvyMeal_Servings").value = newqty;

}

document.getElementById("caspioform").onsubmit=update;

if(document.getElementById("caspioform")) {
document.getElementById("caspioform").style.display = 'none';
setTimeout('document.forms["caspioform"].submit()',1000); }

</SCRIPT>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...