Без jQuery
<HTML>
<head></head>
<body>
<input id="add4" name="add4" type="text" maxlength="2" style="width:30px" value="">
<a href="mainmenu.php?add=3&gr=1">Погнали!</a>
<script>
var inp = document.getElementById("add4");
var links = document.getElementsByTagName("a"); //document.links
links[0].onclick = function () {
this.href = "mainmenu.php?gr=1&add=" + inp.value;
}
</script>
</body>
</HTML>