Access Client Side Script

I have an html_area which I use as an API.

It runs fine however I want to retrieve a value calculated within the client side script, can this be done ?

For example :

html += globals.glbl_ID+'=data.id;'

I’d like to display on my servoy form the value in the global variable globals.glbl_ID

If you are looking for a way to evaluate JavaScript in the browser of a Web client, have a look at the Web Client Utils plugin, on ServoyForge, of course:

Not sure I’ve understood how to use the webclientutils :(

Basically I want to get the value of whatever is in the data.id so I was assuming the variable callback would contain this however it contains a load of scripting.

In other words if data.id was 3 then I want the number 3 returned within Servoy.

markup += 'var id=data.id;'

var callback = plugins.WebClientUtils.addCallback(getID,['id']);

markup += 'function getID(id) {'+callback+'}'

...

function getid(id) {
	
	application.output(id)
}

Ok, I’ve reread whatever documentation I could find and tried various other options includign the following simple test solution which only has a html_area field defined with the data provider as globals.html.

I’d expect the the getid method to be called but it is not invoked … Sorry but I really have no idea how to get this to work.

function onLoad() {

var cb = plugins.WebClientUtils.addCallback(getid,  ['id']);
var js = 'var id=100;my(id);function my(id){'+cb+'}';
globals.html = '<html><head><script type="text/ javascript">'+js+'</script></head></html>'

}

function getid(){

// I expect id to contain the value 100 but this method is never called

	 var id = arguments[0];
        application ('do I get called ????')
        application.output(id)
}

Just tried it here, and this works for me.
What OS/Browser do you use?

Am running a web client on developer (v5.21) through Vista and tried it with both Firefox and IE 7.

I also just slightly modified the sample code by adding the alert, I get the alert displayed but the method is not called (no application.ouitput debug info).

var jsToExecute = "alert('help');var sum = 1 +  2";

plugins.WebClientUtils.executeClientSideJS(jsToExecute,  getid, ['sum'])


}

/**
 * @properties={typeid:24,uuid:"17B737FE-3A5B-47F3-AA0B-9A4AD1AEAE12"}
 */
function getid(){

// I expect id to contain the value 100 but this method is never called

    var id = arguments[0];
        application ('do I get called ????')
        application.output(id)
}

Just tried it on a W7 machine and it works. At least that gives me soemthign to go on.

Hum, yes. I tested on Win 7. Will give it a go on Vista but that’s very strange that there would be any differences.
What Servoy version do you use on 7?

same version both running 5.2.1.

Just even did a reinstall oif 5.2.1 on Vista as I had to install Servoy on the W7 machine. With Vista it does not work.

Yes, I just saw that, tried with Vista/Servoy 5.2.1/IE8.

Actually the problem seems to be coming from the callback in the onLoad/onShow function.
If you do the same script from another type of event (try calling it from a button but with no onLoad call), this works on Vista as well…

I know that there was something fishy about it and I coded a workaround specifically , but I would never have imagined that it would react differently depending on the client OS platform.
I have tested on Win XP and Win 7 with IE7/8 - Firefox 3.6 - Chrome 8 and Mac OS X Snow Leopard with Safari 5 and Firefox 3.6 and didn’t encounter the problem.

Will have a better look at that call from onLoad/onShow, to find a better workaround.

Thanks for the help.