Access text field value via jQuery object $()

sorry but how to access text field with $() ??

<form name=“mainForm”>
<input type=“text” id=“testField” name=“testField”>

<img onclick="document.mainForm.testField.value=‘blah blah text’>

so instead of document.mainForm.testField.value, with jQuery, is it $(‘#testField’).value ??? i know $(‘#testField’).value doesn’t work



sorry but that didn’t work either.

<form name=“mainForm”>
<input type=“text” id=“testField” name=“testField”>
<img src=“s.gif” onclick="$(‘#testField’).val()=‘blah blah text’ ">

what i mean is when clicked on s.gif image, the text ‘blah blah text’ will be inserted into ‘testField’ input field.

original like this onclick=document.mainForm.testField.value=‘blah blah text’

You’re not doing it right:

$('#testField').val('blah blah text');

ok…thanks. However, this is to append new text ‘blah blah text’ to the input field, but how do i get the original text entered into the input field and THEN append ‘blah blah text’, like this

<form name=“mainForm”>
<input type=“text” id=“testField” name=“testField”>
<img src=“s.gif” onclick=" document.mainForm.testField.value+=‘blah blah text’ ">

note the ‘+=’ operator

mean i entered ‘abcd…text text’ into testField input field FIRST, and THEN append ‘blah blah text’ and becomes ‘abcd…text text blah blah text’

this is for onclick=" document.mainForm.testField.value+=‘blah blah text’ "

but $(‘#testField’).val(‘blah blah text’); will wipe out ‘abcd…text text’ and append ‘blah blah text’, now I have ONLY ‘blah blah text’, not the full ‘abcd…text text blah blah text’ I am actually looking for.

I actually making a shoutbox app and need to append smilies along side original text.

sorry if i am asking too much…:blush:

Oops, sorry, here you go:

$('#testField').val( $('#testField').val() + 'blah blah text' );

thank you all for your kind feedback!!