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 post
Share on other sites

7 answers to this question

Recommended Posts

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 post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...