-1
A question I wanted to put a variable inside the link href without using code, which is direct in creating the link.
The example is just below:
<a href="http://websro.correios.com.br/sro_bin/txect01$.QueryList?P_LINGUA=001&P_COD_UNI=" + [CODIGO_RASTREAMENTO] targert="_blank">código de rastreamento</a>
the variable [CODIGO_RASTREAMENTO]
comes from a file Json
that is on the server side.
Note: I cannot use scripts.
I don’t really understand where the variable... of a JSON? on the server side comes from? Of the ways qq the closing quote is misplaced. Explain it better and we can help more.
– Sergio
How is the JSON file? Are you reading it? How is this variable?
– Guilherme Oderdenge
doesn’t matter much where this json file comes from, I just wanted to know the correct placement of the quotes inside href.
– dann
I use a platform called vtex, the json file is generated directly from them and I don’t have access to what comes to min and this json variable [CODIGO_RASTREAMENTO] and just need to insert it in the link.
– dann
Then you get the client-side or server-side JSON??
– Sergio
@Dann I recommend that you change the question title to How to insert Json variable value into a href attribute?
– Leandro Curioso
@Curious Leandrocurious, for me the question is not yet clear. If the JSON is received on the server side the answer is one, if it is on the client side the answer is another...
– Sergio
ok @leandrocurious I’ll do that thank you so much for the info.
– dann
@Sergio agree! Also specify if it’s a server side or client side.
– Leandro Curioso
Okay, so JSON is on the server side.. what language do you have? PHP, Node.JS, ASP ?
– Sergio
I think the author has cooperated to clarify the question I think should not be closed. This comment will be deleted.
– Jorge B.
Dann: What server-side language do you have? PHP? can you put the function that fetches JSON?
– Sergio
@Sergio I honestly do not know what language the staff uses I only have access to frontend this platform VTEX that I use has some restrictions but it is possible to do.
– dann
Okay, and where does this signal code come from
+
?...INGUA=001&P_COD_UNI=" + [CODIGO_RASTREAMENTO]
. I would say that the+
should disappear and the[CODIGO_RASTREAMENTO]
should be before the quotation marks end. But not knowing which language is hard.– Sergio
that part of the code I cannot change to '<a href="http://websro.correios.com.br/sro_bin/txect01$. Querylist? P_LINGUA=001&P_COD_UNI=' comes direct from the site (www.correios.com.br) and this [CODIGO_RASTREAMENTO] I would need to concatenate with the link above.
– dann
because the question is this, if the link is static content you need to know which language to concatenate. Each language has its symbol to concatenate... Can you put a link to this VTEX? I don’t know what it is, maybe there is documentation there.
– Sergio
@Dann, when you’re around, jump into this chat to try and understand the question and maybe help: http://chat.stackexchange.com/rooms/14407/vtext
– Sergio
I did it myself but I tried to write differently.
– dann