Jump to content

How to put JSON message in TPL file?


easymar

Recommended Posts

Hello.

 

I have javascript code:

 function listenMessage(msg) {
        var product = JSON.parse(msg.data); }

and I wanna put variable product.code from this message to:

<input id="product" name="product" value="product.code">

I do not know javascript, maybe for someone it is a piece of cake?

 

 

 

 

 

P.S. I know only how to put this product.code on window popup:

 function listenMessage(msg) {
        var product = JSON.parse(msg.data); }
alert(product.code);
 
 
      
Link to comment
Share on other sites

Based on your code

<input id="product" name="product" value="product.code">

and

function listenMessage(msg) {
        var product = JSON.parse(msg.data); }

the jquery to set the value to the element is as following

$("#product").val(pdocut.code);
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...