On Mon, Oct 19, 2009 at 7:28 PM, ReynierPM <rper...@uci.cu> wrote:

>
> Isn't working.
>
> HTML Code:
> <label for="same" class="first">Same <input type="checkbox" name="same"
> id="same" onclick="doCopy" /></label>
>
> <label for="first_name" class="first">First Name: <input type="text"
> name="first_name" id="first_name" value="" size="" /></label>
> <label for="first_name1">Middle Name: <input type="text" name="first_name1"
> id="first_name1" value="" size="" /></label>
>
> JS Code:
> function doCopy(){
>  $("first_name1").val($("first_name").val())
> }
> Where is the error?
>


Your selectors are incorrect.  $('first_name1') looks for a <first_name>
element in the DOM (there is none).  You're referencing by ID, so you want
to preface the ID with a # sign (similar to CSS).

$('#first_name1').val($('#first_name').val())

-- 
Charlie Griefer
http://charlie.griefer.com/

I have failed as much as I have succeeded. But I love my life. I love my
wife. And I wish you my kind of success.

Reply via email to