Fill form-field in 1 form with the value of a form-field in another form.

Posted on 2012-08-15
Last Modified: 2012-08-16

I'm trying to fill a form-field in 1 form with the value of a form-field in another form.

This is not working for form-fields that are not in the same form, i think.

$("#mainmenu").change( function() {

mainmenu = i n form 1 / mainvalue = in form 2

How can i get it working?
Question by:peps03
    LVL 49

    Expert Comment

    by:Julian Hansen
    Works for me
    <!doctype html>
    <title>EE Test</title>
    <script src=""></script>
    <script type="text/javascript">
    $(function() {
    	$('#mainmenu').change(function() {
    	Form 1<input type="text" id="mainmenu" />
    	Form 2<input type="text" id="mainvalue" />

    Open in new window


    Author Comment

    Oke, thanks
    but it doesn't work here..

    Does it matter that #mainmenu is a select input
    and #mainvalue is a hidden input? i guess not..

    i can't figure out why it wouldn't work.

    Does it matter that there is also an ajax call done in the same change function?
    Creating another change function also didn't help

    BTW, moving the hidden field to the other form also didn't help the problem.. so that's not it.
    LVL 17

    Accepted Solution

    Look at this test page:
    LVL 49

    Expert Comment

    by:Julian Hansen
    Ok two things

    1. Did you try the posted code - did that work or not?
    2. Can you post more of your code or give a link to a page because there is obviously something on your side that has not been described here which is making your solution fail.

    The code I posted works - so if you are using the same logic we need to see more of the code to see why it is not working for you.

    I assume javascript is enabled on the browser ??

    Author Closing Comment

    Thanks for the help!

    This now works. Maybe i had a typo.

    Thanks a million!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
    I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now