24
Views
12
Comments
pass values fromĀ  a javascript funtion
Question


Hi

I need to return values from a javascript function into web screen variables, how can i do this?

thanks

Filipe
2020-03-05 15-52-45
André Vieira
Staff
Hi Filipe,

The only way you have to bind javascript variables with screen variables is to put the value off the first ones in a hidden input field on the page.

Hope this helps.
Cheers,
André
UserImage.jpg
filipe
Hi André

with document.getElementById('wtid').value=10;

i can't modify the input value.

any idea?
2019-10-09 06-46-56
Daniel Lourenço
Staff
Hi Filipe,

Maybe you're using the wrong Id. Try filling in the "name" property of you hidden input (with MyInput, for example) and to generate your javascript use the runtime property MyInput.Id.

Attached I placed a very simple sample eSpace that does that (you need Service Studio 4.1 to open it)

Best Regards,

Daniel Lourenço
TestJSInpuptUpdate.oml
UserImage.jpg
filipe



The problem is that i don't have any submit button to do this.

What i want is onload page get the hostname and put that value in a web screen variable but i'ts not working with the onload submission.


2011-10-11 00-46-16
Diogo Cordeiro
Hi Filipe.

Check Out this topic, to see if it helps.

Then you could just add a screen preparation and fill some local variable, and then set an expression to it...

https://www.outsystems.com/NetworkForums/viewtopic.aspx?TopicId=2863

Best Regards,

Diogo C S Cordeiro
2019-10-09 06-46-56
Daniel Lourenço
Staff
Hi Filipe,

If you want to use a value on a Web Screen that must be processed on the server (like getting the host name), the way to do it is like Diogo said:
1 - Add a screen preparation action to your Web Screen;
2 - In that screen preparation action, place the Outsystems flow that fills in a local variable with the value you want (and for that you'll maybe want to use the extension that is available on the post referenced by Diogo);
3 - Use that local variable in your Web Screen as needed.

If you want to execute a piece of javascript when your Web Screen loads on the client's Web Browser, simply place an "onload" extended property in your Web Screen with the javascript to execute. Attached I placed my sample eSpace that now uses the onload extended property to place the value "Value Placed OnLoad Event" on the "FirstInput" once the page is loaded (see the screen extended properties).

The fact is that I still did not clearly understand what you are trying to do.

Best Regards,

Daniel Lourenço
TestJSInpuptUpdate.oml
UserImage.jpg
filipe
Hi Everybody!

First of all thanks by the help.

Diogo i've already tried the getmachin xif but don´t work for me because runs in the server side and i need to run in the client side. But thanks any way.

Daniel i look at your solution and it's the same that i have implemented and have the same problem.If you look the value from the FirstInput only pass\ to the FirstInputId screen variable when you click the button.Before you click, the screen variable have the null value.

That's my problem because i dont't want to click a button.

thanks a lot.

Filipe

2020-03-05 15-52-45
André Vieira
Staff
Hi Filipe.

Seems to me that you're making it too complicate. Why don't you fill the variable's value in the preparation action? You can do this using the built-in function GetOwnerURLPath() and parsing the value. This function returns the URL path of the eSpace that owns the element that is being processed so it should be something like https://hostname/espace.

Hope this helps. Cheers,
André
UserImage.jpg
filipe
Hi André

Your solution only can give me the localhost from the server side not the client side.

but thanks for help.

Filipe

2020-03-05 15-52-45
André Vieira
Staff
Hi Filipe,

If you want to show the name of the client machine you'll need to inspect the HTTP Request object. I think that you don't have this available in the HTTPRequestHandler extension so you'll need to code the extension yourself.
You can use the GetRequestContent() but this will return the full request as a string and you'll need to parse it.
Probably the best would be to code an extension to return the client hostname using:
HttpContext.Current.Request.UserHostName

Hope this helps. Cheers,
André
UserImage.jpg
filipe
Hi andré

Yes i thinked in your solution to but is giving the server ip.

cheers
GetMachineNameM.xif
UserImage.jpg
filipe
Hi

I think i find the solution.

Is in the Xif attach in this post.

Thanks for the help.

Filipe
GetMachineNameM.xif
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.