Jump to content

Syntax to reference a Field associated with current row of a tabular datapage


Recommended Posts

Hi, this might be a bit advanced..

If i'm using a SubmissionForm Datapage i would be able to use the following to retrieve the value of a field:

var Flag = document.getElementById('UpdateRecordYesNo').value;

but i'm using a Tabular Report Datapage paired with a HTML Block .  I'm trying to get the value of [@field:YesNo] and assign it to a variable called Flag.

Can someone help me with the correct syntax to reference a field associated with the current row of a tabular datapage?

 

<div id="mydiv[@field:CMP_ID2]"> </div>

<SCRIPT LANGUAGE="JavaScript">

var Flag = [@field:YesNo^]

if ( Flag = 1){
document.getElementById("mydiv[@field:CMP_ID2]").innerHTML =   "X" ; 
} else{
document.getElementById("mydiv[@field:CMP_ID2]").innerHTML =   "Y" ; 
}
</SCRIPT>

Link to comment
Share on other sites

Hello @Elderberg,

Please, try to add the addEventListener() method to your code.

Also, change the comparison in the IF condition to this one:  Flag == 'Yes'.

The code example: 
 

<div id="mydiv[@field:CMP_ID2]"> </div>

<script type="text/javascript">

document.addEventListener('DataPageReady', function (event) {

var Flag = "[@field:YesNo^]";

if (Flag == 'Yes'){
document.getElementById("mydiv[@field:CMP_ID2]").innerHTML =   "X" ; 
} else{
document.getElementById("mydiv[@field:CMP_ID2]").innerHTML =   "Y" ; 
}

})
</script>

I hope this information will be helpful. 

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