I have a button on a form which calls a Javascript script this calls a URL with a variable:
If I hardcode the value for the uprn field it works OK, however if I try to set it to a form field it does not.
I know I am doing something silly but I am not very hot when it comes to writing Javascript, any pointer/help would be great.
importPackage(com.ebasetech.xi.api);
importPackage(com.ebasetech.xi.services);
//var uprn = '100060871265';
var uprn = fields.value1.displayValue;
window.open('http://windmz.dartford.gov.uk/myproperty/SquizMyPropertyDetails.aspx?uprn=' + uprn);
Using Ebase variables when calling a URL from Javascript
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 201
- Joined: Fri Dec 20, 2013 1:29 pm
- Location: Dartford Borough Council
- Contact:
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
You can't use window.open on the server - it's only available from Javascript within the browser. You could either:
Server side: use form.displayUrl() or..
Client (browser) side: Use Html Element Properties to add a click event handled on the client (instead of the server) - then you can use window.open
Server side: use form.displayUrl() or..
Client (browser) side: Use Html Element Properties to add a click event handled on the client (instead of the server) - then you can use window.open
0 x
-
- Ebase User
- Posts: 201
- Joined: Fri Dec 20, 2013 1:29 pm
- Location: Dartford Borough Council
- Contact:
Re: Using Ebase variables when calling a URL from Javascript
Many thanks for the help Jon, with your guidance the following code does exactly what we want:
importPackage(com.ebasetech.xi.api);
importPackage(com.ebasetech.xi.services);
var encoder = java.net.URLEncoder;
var encoding = "UTF-8";
var parm1 = encoder.encode(fields.VALUE1.displayValue, encoding);
var url = "http://windmz.dartford.gov.uk/mypropert ... tails.aspx" + "?uprn=" + parm1;
form.displayUrl(url);
importPackage(com.ebasetech.xi.api);
importPackage(com.ebasetech.xi.services);
var encoder = java.net.URLEncoder;
var encoding = "UTF-8";
var parm1 = encoder.encode(fields.VALUE1.displayValue, encoding);
var url = "http://windmz.dartford.gov.uk/mypropert ... tails.aspx" + "?uprn=" + parm1;
form.displayUrl(url);
0 x
Who is online
Users browsing this forum: No registered users and 9 guests