IT-Doctor,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
<script>
window.addEventListener('DOMContentLoaded', function() {
var form = document.querySelector('#forma1'),
phone = form.querySelector("[name='phone']"),
a = document.querySelector('a.gid'),
href = a.getAttribute('href');
phone.addEventListener('input', function(event) {
event.preventDefault();
a.setAttribute('href',href+encodeURIComponent(this.value))
});
});
</script>
</head>
<body>
<div>
<form id='forma1'>
<input type='text' name='phone'></input>
</form>
<a href='http://site1.ru/sms.php?text=' class="gid"><img src='images/img1.jpg'></a>
</div>
</body>
</html>