Jump to content

Fixing concatenate function in JS code


Recommended Posts

Hello,

I have been using the following code in the footer of a details data page. It previously worked to concatenate an autocompleted value from a virtual field with a text area field called "associatedSpecies." This is based on the javascript solution from Caspio below, but I'm not sure if this is no longer supported by more recent browsers? Does anyone have any insight on how I might make this work again?

<SCRIPT LANGUAGE="JavaScript">
function concatenate()
{
var x0 = document.getElementsByName("EditRecordassociatedSpecies")[0].value;
var x1 = document.getElementsByName("cbParamVirtual2")[0].value;

if (x0 && x1) {
 document.getElementsByName("EditRecordassociatedSpecies")[0].value = x0+"; "+x1;
} else { 
 document.getElementsByName("EditRecordassociatedSpecies")[0].value = x0 + x1;
} 

}

document.getElementById("caspioform").onsubmit=concatenate;
</SCRIPT>

 

Link to comment
Share on other sites

Hi @Heineperson

Caspio has stopped supporting onsubmit code:  https://howto.caspio.com/release-notes/caspio-bridge-13-0/13-0-impacted-areas/

Please try the following fix:

<SCRIPT LANGUAGE="JavaScript">
document.addEventListener('BeforeFormSubmit', function (event) {
var x0 = document.getElementsByName("EditRecordassociatedSpecies")[0].value;
var x1 = document.getElementsByName("cbParamVirtual2")[0].value;

if (x0 && x1) {
 document.getElementsByName("EditRecordassociatedSpecies")[0].value = x0+"; "+x1;
} else { 
 document.getElementsByName("EditRecordassociatedSpecies")[0].value = x0 + x1;
} 
});
</SCRIPT>
Link to comment
Share on other sites

  • 5 months later...

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