There is an input field, which, depending on the selected settings, performs either the function of adding to the database or searching the database with the specified mask.
The form itself:
<form method="post"> <p>Π€Π°ΠΌΠΈΠ»ΠΈΡ ΡΡΠ°ΡΡΠ½ΠΈΠΊΠ° : <p><input id="new_partner" name="name_partner" type="text" placeholder="Π€Π°ΠΌΠΈΠ»ΠΈΡ"> <p> Π Π΅ΠΆΠΈΠΌ ΡΠ°Π±ΠΎΡΡ: <p><input id="check" name="option1" type="radio"> ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ Π½ΠΎΠ²ΠΎΠ³ΠΎ ΡΡΠ°ΡΡΠ½ΠΈΠΊΠ° <input id="check" name="option2" type="radio"> ΠΠΎΠΈΡΠΊ ΡΡΠ°ΡΡΠ½ΠΈΠΊΠ° ΠΏΠΎ ΡΠΊΠ°Π·Π°Π½Π½ΠΎΠΉ ΠΌΠ°ΡΠΊΠ΅ <div id="link" hidden> <p>ΠΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ Π½Π°ΡΡΡΠΎΠΉΠΊΠΈ: <p><input id="check" name="option3" type="checkbox"> ΠΠ²ΡΠΎΡΠΎΡΡΠΈΡΠΎΠ²ΠΊΠ° ΡΠ°Π±Π»ΠΈΡΡ ΡΡΠ°ΡΡΠ½ΠΈΠΊΠΎΠ² </div> <p><input type="submit" name="submit" value="ΠΡΠΏΠΎΠ»Π½ΠΈΡΡ" > <input type="submit" name="submit" value="ΠΠΎΡΠΌΠΎΡΡΠ΅ΡΡ Π²Π΅ΡΡ ΡΠΏΠΈΡΠΎΠΊ ΡΡΠ°ΡΡΠ½ΠΈΠΊΠΎΠ²" > </form> How to check the selected radio input settings using ajax, so that when you select the "Search for a participant by the specified mask" option, the script will run below?
The script that performs the search with the specified condition (registered for another input):
$(function() { $("#search").keyup(function(){ var search = $("#search").val(); $.ajax({ type: "POST", url: "/action", data: {"search": search}, cache: false, success: function(response){ $("#resSearch").html(response); } }); return false; }); });