$("input#myinputId").change(function(){//ΠΠ±ΡΠ°Π±ΠΎΡΠΊΠ° ΡΠΎΠ±ΡΡΠΈΡ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΡ. ΠΠ°Π΄ΠΎ ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠΈΡΡ jquery var inputvalue = $(this).val();//Π§ΠΈΡΠ°Π΅ΠΌ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ ΠΈΠ½ΠΏΡΡΠ° $("a.mychanginglink").each(function(index){// Π±Π΅ΡΠ΅ΠΌ Π²ΡΠ΅ ΡΡΡΠ»ΠΊΠΈ, ΠΊΠΎΡΠΎΡΡΠ΅ Π½ΡΠΆΠ½ΠΎ ΠΏΠΎΠΏΡΠ°Π²ΠΈΡΡ ΠΈ ΠΏΡΠΎΠ±Π΅Π³Π°Π΅ΠΌΡΡ ΠΏΠΎ Π½ΠΈΠΌ $(this).attr('href','mypage.php?v='+index+'&s='+inputvalue);//ΠΈΠ·ΠΌΠ΅Π½ΡΠ΅ΠΌ Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠΉ Π°ΡΡΡΠΈΠ±ΡΡ href, ΡΠΎΠ³Π»Π°ΡΠ½ΠΎ ΡΠ°Π±Π»ΠΎΠ½Ρ, ΠΎΠΏΠΈΡΠ°Π½Π½ΠΎΠΌΡ Π² Π·Π°Π΄Π°ΡΠ΅ }); });
native js:
<script> function editLinks(searchvalue){ var anc = new Array(); for(var index=1; index<=3; index++){ anc[index] = document.getElementById('href'+index); anc[index].href = "mypage.php?v="+index+"&s="+searchvalue; } } </script>
HTML:
<input onchange="editLinks(this.value)" name="search" /> <!--<input onkeyup="editLinks(this.value)" name="search" /> - onkeyup Π΄Π»Ρ ΠΌΠ³Π½ΠΎΠ²Π΅Π½Π½ΠΎΠ³ΠΎ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½Ρ. onchange - ΠΏΡΠΈ ΡΠ½ΡΡΠΈΠΈ ΡΠΎΠΊΡΡΠ°--> <a href="#" id="href1">go1</a> <a href="#" id="href2">go2</a> <a href="#" id="href3">go3</a>
native JS for other forms and inputs:
<script> function editInputs(searchvalue){ var inp = new Array(); for(var index=1; index<=3; index++){ inp[index] = document.getElementById('inp'+index); inp[index].value = searchvalue; } } </script>
HTML:
<input onchange="editInputs(this.value)" name="search" /> <!--<input onkeyup="editInputs(this.value)" name="search" /> - onkeyup Π΄Π»Ρ ΠΌΠ³Π½ΠΎΠ²Π΅Π½Π½ΠΎΠ³ΠΎ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½Ρ. onchange - ΠΏΡΠΈ ΡΠ½ΡΡΠΈΠΈ ΡΠΎΠΊΡΡΠ°--> <form action='mypage.php'> <input type='hidden' value="1" name="v" /> <input type='hidden' value="" id="inp1" name="s" /> <button type='submit'>go1</button> </form> <form action='mypage.php'> <input type='hidden' value="2" name="v" /> <input type='hidden' value="" id="inp2" name="s" /> <button type='submit'>go2</button> </form> <form action='mypage.php'> <input type='hidden' value="3" name="v" /> <input type='hidden' value="" id="inp3" name="s" /> <button type='submit'>go3</button> </form>
Itβs still useful to read this: How to set a dynamically changing action attribute for a form