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??
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
...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.
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.
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.
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.
Copy link to clipboard
Copied
check this out
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.
Copy link to clipboard
Copied
I tried but I could not get out of it
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
Copy link to clipboard
Copied
that work! thank you a lot!