Jump to content

Calculating and saving from virtual fields in details page

Recommended Posts

<script type="text/javascript">
function calculate(){
var pm1 =
var pm2 =
var pm3 =
var pm4 =
var pm5 =
var pm6 =

document.getElementById("EditRecordTotal").value = pm1 + pm2 + pm3 + pm4 + pm5 + pm6;


There's my code, I don't know why it's not executing. I tried using the Inspect option in my browser and found this...


Uncaught TypeError: Cannot read property 'value' of null

being called on this line

var pm1 =

The field is not null, so I inspected the field

I inspected that field and the inspector tells me the Id of that field is actually as follows:



So it seems a random set of characters is being added at the end of all my fields, making me unable to "getElementById" since I'll never know what the random set is going to be...


How can I either find out that random set or stop it from being generated? 


Link to comment
Share on other sites

Is Total is number field? If yes then you are concatenating texts and it is not getting saved to number field. To test you can add alert for instance before:


document.getElementById("EditRecordTotal").value = pm1 + pm2 + pm3 + pm4 + pm5 + pm6;



alert(pm1 + pm2 + pm3 + pm4 + pm5 + pm6);

at the beginning after function add alert("Inside Function");


See if you are getting the alerts and see what values you have in

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.

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.

  • Create New...