Initialization of CFv5 values with JS code

bcouvin 16 Jan, 2016
Hello,

I built a form starting with a multifield which is one field and one button. The field ID is named UserInfos.

Under this multifield, I have a serie of text fields which must display the values of my database depending of the value of the #UserInfos.

The goal is to load data (with DB read) from the value of UserInfos when I click on a button.

In my CFv5, in a Designer/Event tab, I make funtion call when I click on the button after entering the value.

In my JS code, I have something like this:

function LoadInfos() {
   user_id=jQuery('#UserInfos').text();
}


In my DB read, I would like to have a Where condition to return data for my table with "user_id" value got from JS code. What is the right syntax to get this value, or what is the right way to get this value?

Thanks in advance for you help.
Bertrand
GreyHead 16 Jan, 2016
Hi Bertrand,

I'm sorry I don't' understand this at all :-(

Where is the DB Read? Are you using an Ajax call to pass data back when the button is clicked? Or does the button Submit the form?

Bob
bcouvin 16 Jan, 2016
Hello Bob,

Today is not a good day for me, I turn around and around (with thoughtlessness)...

I have a form in which when I enter a user_id value and submit this value, I would like to get the information of the user_id in the "same" form.
It seems to be simple, but in fact, my form is in a module. I have also in different modules around with some informations in.

To avoid all my page to reload when I submit this form, I use the button "button" type instead of the submit button type.
This is why I use the function call "LoadInfos" when I click on this button to make some actions from there.

This LoadInfos code is like this:
function LoadInfos() {
   user_id=jQuery('#UserInfos').text();
}


I would like to retrieve the value of user_id above from the field ID #UserInfos. The value of #UserInfos is entered manually.

Bertrand
bcouvin 21 Jan, 2016
Answer
1 Likes
Hello,

Pb solved:
The solution is to use only Chronoform to display the form. All the operations (JS or Php) are done in JS code with ajax on load event. JS/Ajax sends back values to the form and inits values in the corresponding element id of the form.
All the buttons inside tis form are "Button" type, and not "Submit" to avoid to refresh web page. The click on "Button" calls JS/Ajax.

Bertrand
This topic is locked and no more replies can be posted.