• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Collect user input?

Explorer ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

Hi all! I create a little form in captivate that i want to put on my site. In the first slide there are some TEBs to let the user write name, email, company and function. I want to collect that imput in a .txt file or word or webpage or jpg or an email or everything, but i want to take this informations. Have you got a solution??

TOPICS
Advanced

Views

1.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Sep 20, 2018 Sep 20, 2018

I am sure there are more ways then one to do it, but for our purposes let's do it with a javascript snippet.

Assign a variable name to your TEB.  In the example below I am going to use the variable test.

Using javascript and the CP (captivate object) we can pull out.  Assign an action to execute javascript upon hitting the submit button that comes along with your TEB.

In script window use the following:

let myPulledValue =window.cpAPIInterface.

getVariableValue

("test");

You now have whatever was enter

...

Votes

Translate

Translate
Contributor ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

Do you need the information to leave the users machine?  The easiest way to store information is using local storage, which is fairly easy with javascript.  All the other ways you suggest, writing a text file, automating an email etc would require server side code to execute.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

I need the information for me, because we need to contact the people who do the form and we must know the email, name of company ecc.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

OK - then you need server side which really isn't as hard as it sounds (I have slapped it together with very limited knowledge of php a few times now)

Answer these 2 questions -

Are you hosting this on a server, or an LMS?  Are you publishing in HTML?

If you are hosting on a server writing a text or json would be pretty easy with a little ajax magic, its about 8 lines of PHP to catch variables from javascript and write them to a file using PHP.  I could send you stack overflow how-to's, a little more complicated would be to have it email the information automatically using PHP library.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

we are hosting on a server and publish in html. Thanks for your help, my only intention is to save somewhere those informations and be able to see them. i've been looking for all day to find a method to save it but google it's not so helpful.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

check this out

https://teamtreehouse.com/community/sending-an-ajax-request-by-jquery-to-write-to-a-text-file-using-...

You would need to manipulate the cpm.js file or better yet add another .js file to your captivate publish that is loaded from the header in .html or I will also sometimes add them to the lazy loader in html file.  Make sure it loads your custom .js prior to loading cpm.js if you use lazy loader.

Grab the values from you TEB's, and then create the .php on your server that will catch and write the values to a text file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 20, 2018 Sep 20, 2018

Copy link to clipboard

Copied

I tried but I could not get out of it

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 20, 2018 Sep 20, 2018

Copy link to clipboard

Copied

I am sure there are more ways then one to do it, but for our purposes let's do it with a javascript snippet.

Assign a variable name to your TEB.  In the example below I am going to use the variable test.

Using javascript and the CP (captivate object) we can pull out.  Assign an action to execute javascript upon hitting the submit button that comes along with your TEB.

In script window use the following:

let myPulledValue =window.cpAPIInterface.

getVariableValue

("test");

You now have whatever was entered in the TEB assigned to myPulledValue

Now myPulledValue is available to you from javascript.  You could collect all your values, and put into an object, or and array and then write to a file.

One more thing for testing and validation if you are not familiar.  Using chrome command opt J on mac or ctrl opt J on PC.  This will open console, in the same javascript window that we added the above command you can add

console.log(myPulledValue);

Now when you preview HTML5 in browsers, open the console you will be able to see the value that was in your textbox.  Great for verifying and debugging to ensure that you are pulling value out right.

Hope that helps

Brian

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 20, 2018 Sep 20, 2018

Copy link to clipboard

Copied

LATEST

that work! thank you a lot!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources