<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<form class="my-form" action="">
<input class="url" type="text" />
<input class="param-one" type="text" value="tp1__" size="5" />
<input class="param-two" type="text" value="comm_" size="5" />
<input type="submit" value="Результат" />
</form>
<br />
<script>
var myForm = document.querySelector('.my-form'),
url = myForm.querySelector('.url'),
paramOne = myForm.querySelector('.param-one'),
paramTwo = myForm.querySelector('.param-two');
myForm.onsubmit = function() {
var links = {
firstLink: url.value.replace(/(&sub=)([^"']+)/, '$1' + paramOne.value + '$2'),
secondLink: url.value.replace(/(&sub=)([^"']+)/, '$1' + paramOne.value + paramTwo.value + '$2')
};
for(var link in links) {
document.body.insertAdjacentHTML('beforeEnd', '<textarea cols="80"><a class="" href="" data-link="' + links[link] + '">' + link + '</a></textarea>');
}
return false;
};
</script>
</body>
</html>