Jump to content
php.lv forumi

links izmaina input lauka vērtību


Recommended Posts

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 by Grey_Wolf
Link to post
Share on other sites

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 by Grey_Wolf
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...