Jump to content

Referencing Display Only Element with Javascript


Recommended Posts

On a details datapage, updateable fields (for example a caspio Text element) are referenced with JS using document.getElementById ("EditRecordfield").value;

What JS should be used if the field in question is a caspio Display Only element ?

What JS should be used if the field in question is a Hidden element ?

Thanks for your help.

Link to comment
Share on other sites

For the hidden form element the JS is the same as for text field:

I.e. your example is OK: document.getElementById ("EditRecordfield").value;

As for Display only form element, it has difficulty, because it doesn't have id.

I see, the HTML code on details page for the Display only is like the following;

Your_unique_label

Your_value

Think you need:

1) make sure the label for it is unique through the whole details page

2) Get all the

3) Get the value of tag of this element

Link to comment
Share on other sites

Have developed this function.

The following code is to be paste to details page footer:

---------------------------

function i_TR()

{

var TRTags = new Array();

TRTags = document.getElementsByTagName('tr');

var tempInnerHTML;

var tempInnerHTML2;

var SPAN_value = "NOT_FOUND";

var StartIndexOfSpan;

var EndIndexOfSpan;

for (i=0; i

{

tempInnerHTML = TRTags.innerHTML.toString();

if (tempInnerHTML.indexOf('Your_unique_label') != -1)

{

var TRTags2 = new Array();

TRTags2 = TRTags.getElementsByTagName('tr');

for (j=0; j

{

tempInnerHTML2 = TRTags2[j].innerHTML.toString();

if (tempInnerHTML2.indexOf('Your_unique_label') != -1)

{

StartIndexOfSpan = tempInnerHTML2.indexOf('

EndIndexOfSpan = tempInnerHTML2.indexOf('

');

SPAN_value = tempInnerHTML2.substring(StartIndexOfSpan + 25, EndIndexOfSpan);

return SPAN_value;

}

}

}

}

return SPAN_value;

}

Alert

---------------------------

Here I use

Then I read the content of tag and return result.

Pay attention. In case you have several labels like 'Your_unique_label3', 'Your_unique_label', 'Your_unique_label2', this will lead to incorrect results. So, your label should be really unique to use this method.

I also see that value can referenced via HTML block parameter. viewtopic.php?f=3&t=12518 Not tried this yet.

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