Jump to content

Trouble Selecting Value From Calculated Field in Details Page


Recommended Posts

I have a webpage that has a bunch of data pages embedded in it. One of these pages is a Details page.

The Details page has a datasource of my Job Table and it is automatically being filtered by Job Number on load of the page. So, the details page is already showing results for 1 Job when the user loads the page.

I have a calculated field in this Details page that is querying another table to see if any records exist with the same Job Number. If no records exist, then the calculated field equals 0. If there are related records, then the value will be 1.

Now, on my webpage, I am trying to select this value in JS and run a function depending on the calculated value from the Details page. If the value = 0, then I want a modal to pop up. If value = 1, then ignore the function.

I am having trouble getting the value from the calculated field in my JS variable to run the condition on. 

At first glance, it seems it is not possible to select the actual calculated field value from the Details Datapage. It seems the 'EditRecord' element and the actual value are in different elements, and there are no IDs I can make use of to select the value.

puID.thumb.PNG.9c4fb70da7788ff468abaaced6481da6.PNG

 

To combat this, I created a span element with an ID, and just put the calculated value in it.

<span id="puID" style="display:none;">[@calcfield:2]</span>

 

And now I am trying to select the value from id 'puID' to use in my script. But, it doesn't work. When I create a variable and set it to the newly created Span element, console.log successfully shows the entire element. But, when I try to set it as the .value of the element, I get 'undefined'. 

var loadCheck = function(){
  var mmCF = document.getElementById("puID").value;
  console.log(mmCF);
  if (mmCF == 0){
    modalT.style.display = "block";
  }
}

window.onload = function(){
  setTimeout(loadCheck, 1000);
}

puID_und.PNG.9d18294058fd6b221f250e51e824ef3f.PNG

puID_def.PNG.ef40624e332e7b526e1becdca6158c47.PNG

 

Any help would be appreciated.

Link to comment
Share on other sites

I think I figured out the issue.

I could be wrong, but it seems you cannot access the 'value' of a span or div element via JS. I switched '.value' to '.innerText' in my script and it is now working correctly. 

Hope this helps someone.

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

×
×
  • Create New...