How to set variable?

Question for two minutes , help whom not difficult.
// link
var input = document.getElementById('message');
var result = document.getElementById('result');

input.onkeyup = input.oncopy = input.onpaste = input.oncut = (function() {
 return function() {
 var reg = /(http|https)(.*)/g;
 var service = "http://mini.s-shot.ru/?";
 var link = reg.exec(this.value)[0];

 result.innerHTML = "<a href="+link+" target="\"_blank\""><div class="\"url-img\"style=\"background-image:url("+service+link+")\""></div><div class="\"linkwrap\"">"+link+"</div></a><a href="\"javascript:void(0);\"" class="\"remAtt\"" onclick="\"f_url_close()\"" data-balloon="\"Disable\"" data-balloon-pos="\"up\""></a>";
$('#p_url').val(" + link + ");
}
})();
f_url_close function() {
$('#result').html(");
}

I'm asking $('#p_url').val(" + link + ");
And it is necessary that the link went to a variable p_url and then went to the comments.
$('#send').click(function(){ 
$.get(href, function(data) { 
var tmp = href.split('-'); 
$.post('/index/', { 
message: $('#message').val()+"+add_photo.list()+"+add_doc.list()+"+p_url(), 
subs: 0, 
ssid: $('[name="ssid"]', data).val(), 
sos: getSession(data), 
a: 36, 
m: 3, 
id: tmp[tmp.length - 1] 
}, function(res) { 
$('.entry', $(res).text()).prependTo('#wall'); 
$('#wall > div:gt(9)').remove();

// cleanup from the submit form
$('#message').val(");
$('#viewDoc, #imgs, #result').remove();


school55nn.my1.ru/id2
June 27th 19 at 15:02
1 answer
June 27th 19 at 15:04
Solution
Take a variable and then add her link and in the query write the variable without the brackets.

var input = document.getElementById('message');
var result = document.getElementById('result');
var p_url;

input.onkeyup = input.oncopy = input.onpaste = input.oncut = (function() {
 return function() {
 var reg = /(http|https)(.*)/g;
 var service = "http://mini.s-shot.ru/?";
 var link = reg.exec(this.value)[0];

 result.innerHTML = "<a href="+link+" target="\"_blank\""><div class="\"url-img\"style=\"background-image:url("+service+link+")\""></div><div class="\"linkwrap\"">"+link+"</div></a><a href="\"javascript:void(0);\"" class="\"remAtt\"" onclick="\"f_url_close()\"" data-balloon="\"Disable\"" data-balloon-pos="\"up\""></a>";
$('#p_url').val(" + link + ");
p_url = link;
}
})();


// Here is the rule
message: $('#message').val()+"+add_photo.list()+"+add_doc.list()+"+p_url
Thank you very much! - tavares commented on June 27th 19 at 15:07

Find more questions by tags JavaScript