retail666 Posted September 13, 2012 Report Share Posted September 13, 2012 Sveiki. Ir ideja, bet īsti nesaprotu kā lai to realizēju, taādēļ vēršos pie visu zinošajiem php guru! Kā izveidot to, lai uzspiežot uz linka viņš auomātiski izmaina input laukam value. Piemēram ja uzpiež uz linka "pupi", tad input value ir "pupi"? Paldies! Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted September 13, 2012 Report Share Posted September 13, 2012 (edited) elementāri Vatson.. <script> function pupi(id, vertiba){ document.GetElementByID(id).value=vertiba; return false; } </script> <input type="text" id="kautc_kads_id" value=""><a href="Javascript:void(0)" onclick="pupi('kautc_kads_id', 'PUPI'); return false">Pupi</a> <input type="text" id="kautc_kads_id_2" value=""><a href="Javascript:void(0)" onclick="pupi('kautc_kads_id_2', 'Citi PUPI'); return false">Citi Pupi</a> ja gribi tikai vienā input laukā tad vel vienkāršāk <input type="text" id="kautc_kads_id" value=""> <a href="Javascript:void(0)" onclick="document.GetElementByID('kautc_kads_id').value='Pupi';return false">Pupi</a><br> <a href="Javascript:void(0)" onclick="document.GetElementByID('kautc_kads_id').value='Citi Pupi';return false">citi Pupi</a><br> <a href="Javascript:void(0)" onclick="document.GetElementByID('kautc_kads_id').value='Bez Pupiem';return false">Bez Pupiem</a><br> Edited September 13, 2012 by Grey_Wolf Quote Link to comment Share on other sites More sharing options...
briedis Posted September 13, 2012 Report Share Posted September 13, 2012 Vilk, tavs kods nestrādās, jo JS ir case-sensitive. GetElementByID getElementByID Quote Link to comment Share on other sites More sharing options...
ezis Posted September 13, 2012 Report Share Posted September 13, 2012 + rakstīt tādu kaudzi JS - not cool! Quote Link to comment Share on other sites More sharing options...
codez Posted September 13, 2012 Report Share Posted September 13, 2012 http://jsfiddle.net/fBDu9/ $('body').on('click','a',function(){ $('#inp').val($(this).html()); }); Quote Link to comment Share on other sites More sharing options...
daGrevis Posted September 13, 2012 Report Share Posted September 13, 2012 No say... Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted September 14, 2012 Report Share Posted September 14, 2012 (edited) Vilk, tavs kods nestrādās, jo JS ir case-sensitive. GetElementByID getElementByID Taisnība vienk. ātrumā rakstiju, vienkārši parrakstijos :( -- Un šādu sīkumu dēļ dažreiz nočakarējies veelu dienu , meklējot kāpēc nestrādā ... --- http://jsfiddle.net/fBDu9/ $('body').on('click','a',function(){ $('#inp').val($(this).html()); }); aha.. tik aizmirsi piebilst ka līdzi jāvazā paša JQuery bibliotēka ;) Edited September 14, 2012 by Grey_Wolf Quote Link to comment Share on other sites More sharing options...
codez Posted September 14, 2012 Report Share Posted September 14, 2012 aha.. tik aizmirsi piebilst ka līdzi jāvazā paša JQuery bibliotēka ;) Ieliec linku no google cdn un 99,9%, ka tev jau tā bibliotēka būs pārlūka kešā. Quote Link to comment Share on other sites More sharing options...
indoom Posted September 14, 2012 Report Share Posted September 14, 2012 Tas pats bez jQuery http://jsfiddle.net/fBDu9/2/ document.body.onclick = function(e) { e = e || window.event; var t = e.target || e.srcElement; if (t.tagName.toUpperCase() === 'A') { document.getElementById('inp').value = t.text||t.textContent||t.innerHTML; } }; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.