Jump to content
  • 0

Passing Data From A Virtual Field To A Non-Virtual Field


ababcock

Question

In my submission form, I have created a virtual cascading text field to pull data from one of my tables because that was the only way to get text longer than 255 characters to carry over. 

 

Now, I want to save that information on a new table alongside the new information entered on the submission form, but I don't know how to get the data to carry over. I thought maybe I should set it up as a parameter to pass from the virtual field to the hidden non-virtual field, but that doesn't seem to be working. It's quite possible I'm just not doing it right. 

 

Any suggestions on how to achieve this?

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Hello ababcock !

 

You can achieve this by using JavaScript . The sample is as follows :

<SCRIPT LANGUAGE="JavaScript">

function concatenate()
{
var x = document.getElementsByName("cbParamVirtual1")[0].value;

document.getElementById("InsertRecordYour_Field").value = x;

}

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

If you have 2 or more Virtual Fields you just need to change number in the following name of the parameter - "cbParamVirtual1" ( i.e cbParamVirtual2 , cbParamVirtual3) 

 

I hope this helps you

 

Have a good day 

 

Aurora :)

Link to comment
Share on other sites

  • 0

I tried using this JavaScript in my submission for and I am getting the error message

You did not enter valid information in one or more of the fields.

 

Below is the JaveScript I am using in the footer of a submission form. I am trying to pass the value of Virtual5 (text field) to the underlying table field SchoolName. I have other virtual fields on the form, but this is the only being referenced in the JavaScript

Thank you
------------------------------------------------------//////////////////////////////////////

<SCRIPT LANGUAGE="JavaScript">
function concatenate()
{
var x = document.getElementById("cbParamVirtual5")[0].value;
document.getElementById("InsertRecordSchoolName").value = x;
}
document.getElementById("caspioform").onsubmit=concatenate;
</SCRIPT>

Link to comment
Share on other sites

  • 0

Hi,

 

do you have cascading text fields?

 

If you have regular text field, the code will be.

<SCRIPT LANGUAGE="JavaScript">
function concatenate()
{
var x = document.getElementById("cbParamVirtual5").value;
document.getElementById("InsertRecordSchoolName").value = x;
}
document.getElementById("caspioform").onsubmit=concatenate;
</SCRIPT>

I've deleted [0]

 

Also please make sure that name of the field in the table is SchoolName. Names are case sensitive. 

 

Hope it helps

Link to comment
Share on other sites

  • 0

Hi,

 

i think you forget the " s " in getElementsByName("cbParamVirtual5")[0].value;
 

and if you want to check if the variable x is taking the good value you can write:

alert ( x );

//alert show a popup with the value of x,
//you can use this function to test your code whenever you have a problem of values.
// don't forget to remove the alert when you get it to work

Olfa

Link to comment
Share on other sites

  • 0

Hi,

 

This particular example is a text field. I used the suggested code above by Mathilda and I see a new row is created on submit, but the virtual field does not copy the value over to the underlying table field.

 

I have another example where I need to implement this with multiple virtual fields, some of which will be cascading. I am testing now with this single virtual field and completely puzzled as to why it won't work.

 

I appreciate any tips at this point!

Link to comment
Share on other sites

  • 0

Okay, I got this working now. Before I fixed the issue, I was not loading and hiding the underlying field "SchoolName" into the datapage. I selected my table field "SchoolName" and added it to my list of fields. I then wrapped two html blocks around the field to hide it so it is not displaying on my form. Only then would the JavaScript work as it apparently needs the field on the page somewhere to reference it for writing to the underlying table. It this obvious to others, it was certainly not obvious to me. To test this...when I removed the "SchoolName" field from my form, I could no longer write to the field using the script.

 

<table style="display:none">

</table>

Link to comment
Share on other sites

  • 0

Hi, 

 

Yes, to be able to write the value in the field, you should add this field to your form.

 

Here is an article which explain how to hide fields on Form datapage.

 

I'm glad that script works.

 

Since you are using Java Script,  I would like to recommend you using developer tools for debugging Java Script code. Press F12 to call developer tools in Chrome an IE or install firebug free add-on for Firefox.

If there are any errors in your code you'll see them in console.

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
Answer this question...

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