Показать сообщение отдельно
  #8 (permalink)  
Старый 05.06.2017, 15:59
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,133

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>
Ответить с цитированием