Skip to main content
Inspiring
September 19, 2018
Answered

Collect user input?

  • September 19, 2018
  • 1 reply
  • 1523 views

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

This topic has been closed for replies.
Correct answer thisguy4xapi

I tried but I could not get out of it


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

1 reply

thisguy4xapi
Inspiring
September 19, 2018

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.

Inspiring
September 19, 2018

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.

thisguy4xapi
Inspiring
September 19, 2018

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.