Good all the time of day.

Page_1, input (name = 'search'), next to the hunt to make 3 buttons, per page_2, which will search entered in the 'input'. Buttons 3, because it will be necessary to search in different places, and I cannot understand how to add the value from the β€œinput” to the link, since The link is loaded already ready, and the value is entered into the 'input'.

Tell me how to organize this?

ps links while not in working form are:

 <a href="mypage.php?v=1&s=Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅_ΠΈΠ½ΠΏΡƒΡ‚Π°"> <a href="mypage.php?v=2&s=Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅_ΠΈΠ½ΠΏΡƒΡ‚Π°"> <a href="mypage.php?v=3&s=Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅_ΠΈΠ½ΠΏΡƒΡ‚Π°"> 

    3 answers 3

     $("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

    • one
      Added comments. - knes
    • Prescribed it that way. None of the links worked. Just go to mypage.php # (only the grid is added). And you can find out, stupidly horrible option: how to make 3 forms, with 1 input in each (type = "hidden"), which will be automatically equal to the first input that I fill out? - sergey
    • 2
      Well, here's your native JS. What is the problem? =) - knes
    • I tried, did not work. (And if the code worked, I would have liked it.) - sergey
    • one
      Oh yes. If you want to change in real time, and not when you focus off, replace onchange with onkeyup - knes

    Make a form, enter a value, copy the links, and you will have 4 buttons. What page encoding is it? .. Text in Russian?

    • Encoding 1251, the text in Russian. Copy from where to where? More detail you can? Maybe then 3 forms, with hidden inputs, which will be somehow equal to the visible input, and then this is as an option. - sergey
    • I understand that you need something like <a href="mypage.php?v=1&s=%D0%B7%D0%BD...">Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅_ΠΈΠ½ΠΏΡƒΡ‚Π°</a> . In the search engines write the key, and copy the address, the easiest way - here is the link mypage.php?v=1&s=%D0%B7%D0%... Also note that in the URL you get the value in utf-8, you need to follow this, if your pkhp. - coderxlsn
    • Gentlemen, let us dwell on how when filling an input (which does not belong to any of the forms), automatically fill in the input (3pcs) in other forms, and make them hidden, the rest will not be difficult. - sergey
    • as well, only instead of links and hrefov - input and values: inp [index] .value = "searchvalue"; - knes
     <input type='text' name='s1'> <form action="mypage.php?v=1" method="post" name="form"> <input type='text' name='v1' onKeyUp="var i1 = document.getElementById('v1'); var i2 = document.getElementById('s1'); i1.onkeyup = function(){ i1.value = i2.value;}"> <input name="submit" type="submit" value="ΠΊΠ½ΠΎΠΏΠΊΠ°1"> <form action="mypage.php?v=2" method="post" name="form"> <input type='text' name='v2' onKeyUp="var i3 = document.getElementById('v2'); var i4 = document.getElementById('s1'); i3.onkeyup = function(){ i3.value = i4.value;}"> <input name="submit" type="submit" value="ΠΊΠ½ΠΎΠΏΠΊΠ°2"> <form action="mypage.php?v=3" method="post" name="form"> <input type='text' name='v3' onKeyUp="var i5 = document.getElementById('v3'); var i6 = document.getElementById('s1'); i5.onkeyup = function(){ i5.value = i6.value;}"> <input name="submit" type="submit" value="ΠΊΠ½ΠΎΠΏΠΊΠ°3"> 

    I mean that kind of this construct. she is not working, now I'm looking for shoals in it. if someone tell me I will be glad. using this without jquery, js

    • one
      Well, something like this. Only copy it neatly: <input type = 'text' name = 's1' id = 's1'> <form action = "mypage.php? V = 1" method = "post" name = "form"> <input type = 'text' name = 'v1' id = 'v1' onKeyUp = "var i1 = document.getElementById ('v1'); var i2 = document.getElementById ('s1'); i1.value = i2.value;"> <input name = "submit" type = "submit" value = "button1"> And so - almost everything is correct. But the meaning of this construction is a mystery to me. =)))))) - knes
    • uh ... already tried to enter id, even in this form the construction does not work - sergey
    • pruflink Everything works fine for me: when we try to change the input named v1, v2 ... we are persistently returned the value s1 - knes
    • If I set the cursor in "name = 'v1' id = 'v1'" and press erase - the same value becomes from "name = 's1' id = 's1'", but that's why not immediately - I do not understand. - sergey
    • one
      not immediately, because you have written onkeyUP. It would be onkeyPRESS immediately, but then it would be erased (if erased) or added (if you write) - knes