0

Not quite sure how to arrange this question.

Basically, I have a page with 4 forms all in separate tabs, (3 for each department and an admin overview with all forms on), what I would like to do is once the input has changed in one of the 3 departmental forms duplicate that input into the same field in the admin form.

What I'm currently using is the following

jQuery(".volume").keyup(function(){
        var volume = jQuery(".volume").val();
        jQuery('.volume').val(volume);
        });

this works fine in it self, but what I would like is to be able to have a little function like this that automatically works on any input, textarea and select.

Would anyone be able to advise me on how to put something like that together?

Thanks in advance.

1
  • Apologies, copied and edited the wrong snippet. was originally duplicating too another ID. edited to reflect that Commented Aug 30, 2012 at 13:32

1 Answer 1

3

Try

jQuery("input").keyup(function() {
    var volume = jQuery(this).val();
    jQuery("input[name=" + jQuery(this).attr("name") + "]").val(volume);
});
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, had to make a few tweaks to get it working by name, works well though!jQuery("input").keyup(function() { var vol = jQuery(this).val(); var cla = jQuery(this).attr("name"); var name = 'input[name="'+cla+'"]'; jQuery(name).val(vol); });
you're welcome - updated the answer to reflect your case better
didn't have much luck with prop, however attr worked a treat.
what version of jQuery are you using?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.