Jump to content

Edit Page Suddenly Not Working


Recommended Posts

I have a details page where users edit their time sheets entries. It shows the original times entered and has fields for new times. It was working fine, but now it is not updating. They click the update button, but it doesn't record any of their new data. I looked at the page with the Developer View on Chrome, and it shows this error: "Uncaught TypeError: Cannot set property 'onmouseover' of null" I will paste the footer script below. Please help me figure out what's wrong with it!

<script>

document.getElementById('Mod0EditRecord').onmouseover = function(){

var date = document.getElementById('EditRecordDate').value;
if(date == "")
date = "1/1/2011";
var hour = document.getElementById('cbParamVirtual1').value;
if(hour =="")
hour="00";
var minute = document.getElementById('cbParamVirtual2').value;
if(minute == "")
minute = "00";
var ampm = document.getElementById('cbParamVirtual3').value;

document.getElementById('EditRecordStart_Time').value = date + " " + hour + ":" + minute + " " + ampm;


var hour2 = document.getElementById('cbParamVirtual4').value;

if(hour2 =="")

hour2="00";

var minute2 = document.getElementById('cbParamVirtual5').value;

if(minute2 == "")

minute2 = "00";

var ampm2 = document.getElementById('cbParamVirtual6').value;

document.getElementById('EditRecordEnd_Time').value = date + " " + hour2 + ":" + minute2 + " " + ampm2;
var start= new Date(document.getElementById('EditRecordStart_Time').value);
var end = new Date(document.getElementById('EditRecordEnd_Time').value);
var timeDiff = end - start;
var hh = Math.floor(timeDiff / 1000 / 60 / 60);

timeDiff -= hh * 1000 * 60 * 60;

var mm = Math.floor(timeDiff / 1000 / 60);

var totalmin= (mm+ (hh * 60)) ;
document.getElementById('EditRecordHours').value =  (totalmin/60).toFixed(2);

};


</script>

Link to comment
Share on other sites

Hi @ababcock,

I think the issue caused by the invalid way how you try to reference the Update button.

document.getElementById('Mod0EditRecord').onmouseover = ...

Caspio has recently introduced some changes in the way how ID of the element is generated.

Unique postfix has been added to each element of a Datapage.

jglYwu2.png

You can use CSS selectors to get the element by partial name e.g. 

document.querySelector("input[id^='Mod0EditRecord']")

or by using class to refer to the Update button e.g.

document.getElementsByClassName('cbUpdateButton')[0];

Hope this helps.

Regards,

vitalikssssss

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