Spip - Passing data from Javascript to hidden input value

106 Views Asked by At

J'm trying to pass some data from javascript to #ENV in hidden input value, in CVT form. In the form i have some radio inputs which are working fine and one hidden input to get the leaflet coordinates stored in js variable. My input looks lick that:

<input value='#ENV{localisation, #GET{coord}} 'name="localisation" type="hidden"></input>

and my code:

[(#SET{coord, JSON.stringify(latlng_tab)})];

In the

console.log (#ENV{localisation, #GET{coord}}) 

I can see the coordinates but it doesn't work in input. Can someone help me, please.

1

There are 1 best solutions below

0
On

In case someone will be looking for an answer. I had to remove #GET from input and #SET from the code and instead i'm using that:

<input  id="localisation" value='' name="localisation"  type="hidden">
</input>

var latlng_str = document.getElementById("localisation");
latlng_str.value = JSON.stringify(latlng_tab);