There is the following code:
$("#fio_pokup").keydown(function(e){ id_box = $(this).attr("id"); quer = $("#fio_pokup").val();; //присваиваем переменную if (e.keyCode == '13') { //если нажат Enter if(quer!='') { //если переменная не пустая $(this).addClass('true'); jQuery.ajax({ type: "POST", //тип запроса url: "modules/kvitok/update.php", //куда далаем запрос dataType:"json", // тип json data:{ value: quer, // данные sid: session_id, // сессионная переменная id: id_box //имя id атрибута }, //отправляем данные success:function(data){ var res = jQuery.parseJSON(data); //парсим ответ if (res["msg"]=="Ok"){ // если все ОК $.unblockUI(); // отображаем всплывающее окно $.growlUI('Успешно!', 'Фамилия покупателя установлена!'); //сообщение в окне } else{ // если все плохо if (confirm(res["msg"])) { //показываем сообщение close(); // закрываем окно } } }, error:function (xhr, ajaxOptions, thrownError){ alert(thrownError); //выводим ошибку } }); }}}); it catches pressing Enter only in the field with id = fio_pokup. To do the same code for each field - not by Feng Shui, in connection with which id_box was entered, which will send this id to the server, indicating which field the data was sent from. Further, the form is:
<div id="kvitok"> <input type="text" size="50" maxlength="100" value="" id="fio_pokup"/><br> <input type="text" size="50" maxlength="100" value="" id="adress_pokup"/> </div> Question: How to edit this code so that it: 1) Catch any press Enter where div id = "kvitok" 2) Calculate the input id 3) Calculate the value of the input