There is a pop-up window with a contact form in which there is an input. Its value should be changed depending on the button that the user clicked on. For what I decided to use the data- * value.

The solutions I tested from the open spaces do not work. For example, this:

<a data-auto="1123" class="btn-success">Заказать</a> <form> <input id="someuniqid" type="text" readonly> <input type="submit" value="Отправить"> </form> <script> $('a.btn-success').on('click',function(){ var mysuperdata = $(this).attr('data-auto'); $('input#someuniqid').val(mysuperdata); alert("ох ты ж епт"); }); </script> 

Please tell me how to do it wisely and / or why the solution does not work.

  • Well, why does it work for me, tell me, but the pop-up window is not loaded by Ajax? - Arendach
  • https: // rent-auto92.ru/ prices / (remove spaces) Click order opposite "Chevrolet Aveo". Does not work even without a window. - Denis Kanaev

1 answer 1

You interrupt interception, which is lower

 jQuery('.btn-success').click(function() { 

than your

 $('a.btn-success').on('click',function(){ 

Are the fix options clear?

  • Please tell me, I never mastered javascript. - Denis Kanaev
  • Well, place the code of two functions in one - Nsk
  • I did not work out, will you? And plz tell me how did you determine that one code is interrupting another? - Denis Kanaev