Is there any way to pass variables into a javascript? And is there any reference about passing gloable variables?
Thanks
Zhe
Answers7
WH
WH2008-07-18
You can use the JavaScript component to output a script into the header or body of the document.
You can use macro substitution to insert global variables. For example,
var x = '$(x)';
Alternatively, you can change the type of the script parameter to expression type and just create a string using PilotScript.
"var x = '" . @x . "';"
If you have a lot of data to write out, consider using the JSON Writer to write a file to the job directory, and then either load it using AJAX from the report, or read it back in with a Text Writer and include it in the report using an ExpressionType JavaScript component.
HP
HP2008-07-18
Thanks,Warren. But I am still confused. My current problem is to create a file loader by arranging a table on the page with a file chooser under it. Once the user choose a delimited file after they browse the file, they can preview the data in the table above instantly.Is there any way to accomplish this function. Thanks for your support.
Zhe
WH
WH2008-07-18
Hi Zhe,
You can use the Protocol Function component to output a function that will execute a function and then call a function of yours with the first result file when the protocol completes.
If you define a protocol that just copies the selected file (which is a protocol level parameter) into the job directory, this should execute pretty quickly.
Have a look at the "Update Chart Axis via Callback Function" example for some pointers.
HP
HP2008-07-21
quote:
"Update Chart Axis via Callback Function"
Hi,Warran,
Where is the "Update Chart Axis via Callback Function" example, I can't find it. Thanks
WH
WH2008-07-21
Hi Zhe,
The "Update Chart Axis via Callback Function" example is in the "SciTegic Examples/Reporting/JavaScript/AJAX" folder, and was new in 7.0. I'm attaching a modified version of the example and its dependent protocol that will work in 6.1.5 -- you will have to update the shortcut after importing both protocols.
HP
HP2008-12-31
hi,
I want to increment the value of pilot script variable through javascript
eg: if in pp @next := 1;
in javascript i want to increment this variable,
WH
WH2009-01-05
You have to run a protocol from your browser in order to pick up a value that has been updated via JavaScript. The Protocol Function component used in the previous example in this thread is one way to do this. An Input Form component is an even simpler way. Have a look at the attached example, which takes user input, performs a JavaScript operation in the browser (adding two numbers), and then passes the result back to Pipeline Pilot by re-running the same protocol.
You can use macro substitution to insert global variables. For example,
var x = '$(x)';
Alternatively, you can change the type of the script parameter to expression type and just create a string using PilotScript.
"var x = '" . @x . "';"
If you have a lot of data to write out, consider using the JSON Writer to write a file to the job directory, and then either load it using AJAX from the report, or read it back in with a Text Writer and include it in the report using an ExpressionType JavaScript component.
But I am still confused. My current problem is to create a file loader by arranging a table on the page with a file chooser under it. Once the user choose a delimited file after they browse the file, they can preview the data in the table above instantly.Is there any way to accomplish this function.
Thanks for your support.
Zhe
You can use the Protocol Function component to output a function that will execute a function and then call a function of yours with the first result file when the protocol completes.
If you define a protocol that just copies the selected file (which is a protocol level parameter) into the job directory, this should execute pretty quickly.
Have a look at the "Update Chart Axis via Callback Function" example for some pointers.
Hi,Warran,
Where is the "Update Chart Axis via Callback Function" example, I can't find it.
Thanks
The "Update Chart Axis via Callback Function" example is in the "SciTegic Examples/Reporting/JavaScript/AJAX" folder, and was new in 7.0. I'm attaching a modified version of the example and its dependent protocol that will work in 6.1.5 -- you will have to update the shortcut after importing both protocols.
I want to increment the value of pilot script variable through javascript
eg: if in pp @next := 1;
in javascript i want to increment this variable,