[World Map] Save selected country JVectorMap

Forge Component
(4)
Published on 2015-07-30 by Gonçalo Borrêga
4 votes
Published on 2015-07-30 by Gonçalo Borrêga

Hello,

I'm trying to save the selected country name on a local variable in order to use on another screen.

I've tried some JS Scripts without success.


Could you please help me on this ?


I'm using the latest version of JVector Map on Oustystems 11.


Thank you

Hi Luca,

You'll need to create a variable, and use it in a hidden (use CSS display:none) input on the page.
Then you can write the value to the input box with jQuery and you'll see the value on the variable on the next request.

You will need these 'hacks' to write to outsystems variables with JS.

best,

HD

Hélio Dolores wrote:

Hi Luca,

You'll need to create a variable, and use it in a hidden (use CSS display:none) input on the page.
Then you can write the value to the input box with jQuery and you'll see the value on the variable on the next request.

You will need these 'hacks' to write to outsystems variables with JS.

best,

HD


Hello Hélio, 

First, I want to thank you for your reply!

I'm new at this, and I don't have much experience on JQuery or JS.


I'm trying to make it work, but without success.

What i did was to create a local variable as you said, and now I want to write it on that input box but i dont know how I can do it.

I can see that in the map there is an option called "JavascriptOnRegionSelected", should I use this ?

The Region selected is the same as Country Selected ?


Also i've inspected the map to understand if there is any id to use, but this is what I see:

"<div class="jvectormap-tip" style="display: block; left: 300px; top: 421px;">Portugal</div>"


If you can provide me an example for me to see how to do it, I would be very thankful.


Thank you!

Solution

In this attached example I'm running a piece of JavaScript to write to a variable through an hidden input parameter.

I really don't remember how this component works.. it was published many years ago.
If you follow this approach you should be able to push javascript values to OutSystems variables. 


You don't need to run the javascript using the RunJavascript action, but that's the only way to reference the input Id. Alternatively, you can set a CSS class and use $('.class-name') instead of $('#id').

regards,
Hélio

Solution