Jump to content
  • 0

Update existing value in hidden field?



I'm new to JavaScript in Caspio, and I've hit a wall.

On an update web form, I'm trying to add a user-supplied value (User_rating) to an existing value in a hidden field (Total_rating).

I've got the calculation working, but only when "Total_rating" is a visible text field.

The script automatically plugs in the sum before it jumps to the destination page. That's the part I'd like to hide behind the scenes.

This is based on Caspio's posted Calculator JavaScript, but I think Step 4 is where the problem is.


function calculate()

//Step 1 Get User_rating value
var user = parseFloat(document.getElementById('caspioform').EditRecordUser_rating.value); 
//Step 2 Get Total_rating value
var total = parseFloat(document.getElementById('caspioform').EditRecordTotal_rating.value); 

//Step 3 Add User_rating to Total_rating
var newtotal = (user + total); 

//Step 4 Update Total_rating
document.getElementById('caspioform').EditRecordTotal_rating.value = Math.round(newtotal);


//Step 5 Calculate

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0


The hidden field has the same element id on the page. To make sure you can check its id by looking at the source code of the page. So grab the DataPage URL from deployment wizard, open in a browser and view source. Then look for the Total_rating and find its id.



Link to comment
Share on other sites

  • 0

You may try using  Calculated Value on this. As Caspio release new features, this includes the calculated value. Calculated Value is a form element that allows you to generate calculations which you can use for your total rating. 

Check these videos for more information:

I hope this helps!

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.

Answer this question...

×   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.

  • Create New...