172
rated 0 times
[
176]
[
4]
/ answers: 1 / hits: 55928
/ 14 Years ago, sun, october 31, 2010, 12:00:00
I'm trying to figure out how to copy a users text input in one form field to another. Specifically, when someone fills in their email address in the contact form, it will be duplicated in the mailing list form.
Both these forms are using ajax so there's no concerns about the input text being lost on submit.
This is the code I have:
<div id=contact_form>
<form name=contact method=post action=>
<input type=text name=name id=name size=30 value=Name class=text-input />
<label class=error for=name id=name_error>Please enter your name.</label>
<br />
<input type=text name=email id=email size=30 value=Email class=text-input />
<label class=error for=email id=email_error>I need your email.</label>
<br />
<textarea rows=10 cols=30 type=textarea name=message id=message value=Message class=text-input ></textarea>
<label class=error for=message id=message_error>A message is required.</label>
<br />
<input type=submit name=submit class=button id=submit value=Send />
</form>
</div>
<div id=details>
<p>some details here, not sure what yet</p>
</div>
<div id=mail_list>
<input type=text id=mail value=Your email name=mail_list /><input type=submit name=submit class=button id=submit value=Send />
</div>
I found this in the Jquery documentation, but couldn't get it to work:
$(#email).optionCopyTo(#mail);
Thanks!
More From » jquery