Jump to content

Copy Virtual Field to Text Area Field on the fly


Recommended Posts

Hi

Hope someone can help me out here with my javascript problem.

I have a submission form (which is multi-step form, 2nd page of a form which is now a update form) which is collecting information like

project type, project name, description. It is cascading from project type -> project name -> description

Because I can't do a cascading text area for "description". I have created a virtual text field for this value hoping to copy this into the "description" text area.

 

I am having no luck with javscript which I have modify from what i found on this forum. Can someone please help me? This is what I have came up with.

 

<script type="text/javascript">
    // Caspio form elements
    var description = document.getElementById('EditRecordDescription');
    var temp_description   = getElementsByName("cbParamVirtual1")[0].value;
    var caspioForm = document.getElementById('caspioform');

 

    // Event handler
    var Copy = function ()
    {
        // TODO: assign value to description field
       description.innerHTML = temp_description;
    }

document.getElementById("caspioform").onload= Copy;

</script>

 

 

Link to comment
Share on other sites

  • 4 weeks later...

I can't tell when you want the data copied based on your question, so I'll try to help, assuming you want the description copied after the user types a description.

<script>
var caspioDescriptionElement = document.getElementById('EditRecordDescription');
var formDescriptionElement = document.getElementById("cbParamVirtual1");
  
formDescriptionElement.onchange = function() {
   caspioDescriptionElement.value = formDescriptionElement.value;
}
</script>

While writing this, I noticed that you're missing a "document" before  "getElementsByName("cbParamVirtual1")[0].value; ". That might fix your code.

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