PIH variable value from js


python inside html question.
what is the syntax to pass a value to PIH variable from js?

alert('The value passed is: '+val);
<% node = val %>

is it possible to pass val to node?


The python is evaluated on the gateway before being sent via http to the client which runs the js in the browser. So there is no way to do this inline, I would suggest using an ajax type solution(a nice explanation: http://www.adaptivepath.com/ideas/essays/archives/000385.php). Use an http request (http://en.wikipedia.org/wiki/XMLHttpRequest) to send the variable to the gateway, the response can then contain js or html that would be evaluated on the client in turn or used to update a portion of the page.

Many ajax libraries exist that make this type of interaction simpler (prototype, jquery, dojo, extjs etc). Due to size restrictions on the device if you can have the client access both gateway and the internet google, yahooo, aol and such provide hosting of these libraries which may work better then placing them directly on the device (i.e. http://code.google.com/apis/ajaxlibs/).

any other ideas?

any ideas?
is it possible to put any value from html object into PIH (Python Inside HTML) line? any replacement chars?

<% setsdout("%> html_obj_value <%", ‘0’, ‘-1’, ‘-1’, ‘-1’) %>


I would suggest reading http://karrigell.sourceforge.net/en/pythoninsidehtml.htm as mentioned in the wiki, it is where the templating system comes from(http://www.digi.com/wiki/developer/index.php/Python_inside_HTML). Checking out the project from kerrigell can be valuable as there is a PIHapp.py script which is a small GUI application that shows how PIH files are translated into Python scripts which are executed on the gateway and the result sent to the client.


thanks for information.
PIHapp.py doesn’t seem to work on X4.
and concerning PythonInsideHTML.zip‎ … …i smell a full rewrite of the whole service. that i dont want.