Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8041659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:17:44+00:00 2026-06-05T04:17:44+00:00

I have three modules/sectinos that basically do the same thing with some minor differences.

  • 0

I have three modules/sectinos that basically do the same thing with some minor differences. I tried to write the main portion into a jquery function so I can just call it as needed, but I can’t structure it correctly. Could someone show me how to structure this please?

This is the part I need as a separate function and then called by the others

var mytextareaFld = $('#ta_holdAll');
        var fld_1 = $('#firstname').attr('name')+':  '+$('#firstname').val();
        var fld_2 = $('#lastname').attr('name')+':  '+$('#lastname').val();
        var fld_3 = $('#street_number').attr('name')+':  '+$('#street_number').val();
        mytextareaFld.val(fld_1 +'\n' + fld_2 +'\n' + fld_3);

jsfiddle: http://jsfiddle.net/justmelat/v4sZb/

html/jquery code below:

<form>
    <p>First name: <input type="text" name="firstname" id="firstname" value="Paul"/></p>
    <p>Last name: <input type="text" name="lastname"  id="lastname" value="Ryan" /></p>
<p>Street #: <input type="text" name="street_number"  id="street_number" value="4605"/></p>
<p>Address: <input type="text" name="address" id="address"/></p>
<p>City: <input type="text" name="city" id="city" /></p>
<p>State: <input type="text" name="state" id="state"/>

<span id="myzip">Zip:</span> <input type="text" name="zip"  id="zip" />
    <br /><br />
<span id="allInfo">All Info:</span> <textarea id="ta_holdAll" rows="10" cols="30"></textarea><div id="charCnt"></div><br /><br />
    <input type="button" value="Add to Field" id="addField">
</form>

    $(document).ready(function(){
    $('#addField').on('click',function(){
        var mytextareaFld = $('#ta_holdAll');
        var fld_1 = $('#firstname').attr('name')+':  '+$('#firstname').val();
        var fld_2 = $('#lastname').attr('name')+':  '+$('#lastname').val();
        var fld_3 = $('#street_number').attr('name')+':  '+$('#street_number').val();
        mytextareaFld.val(fld_1 +'\n' + fld_2 +'\n' + fld_3);
    });

    $('#allInfo').on('click',function(){
        var mytextareaFld = $('#ta_holdAll');
        var fld_1 = $('#firstname').attr('name')+':  '+$('#firstname').val();
        var fld_2 = $('#lastname').attr('name')+':  '+$('#lastname').val();
        var fld_3 = $('#street_number').attr('name')+':  '+$('#street_number').val();
        mytextareaFld.val(fld_1 +'\n' + fld_2 +'\n' + fld_3);
        var $mytextareaFld = $('#ta_holdAll');
        var $outPutCount = $("#charCnt");
        var $ofText = " characters of 1000 remaining";
        var val = $mytextareaFld.val();
        var val2 = $outPutCount.text(val.length).append("<strong>"+$ofText+"</strong>");
    });

    $("#firstname,#lastname, #street_number").blur(function(){
        var mytextareaFld = $('#ta_holdAll');
        var fld_1 = $('#firstname').attr('name')+':  '+$('#firstname').val();
        var fld_2 = $('#lastname').attr('name')+':  '+$('#lastname').val();
        var fld_3 = $('#street_number').attr('name')+':  '+$('#street_number').val();
        mytextareaFld.val(fld_1 +'\n' + fld_2 +'\n' + fld_3);
    });
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:17:46+00:00Added an answer on June 5, 2026 at 4:17 am

    JS Fiddle Demo: http://jsfiddle.net/lucuma/jmhmE/1/

    $(document).ready(function(){
    
        function AddStuff(event) {
              var mytextareaFld = $('#ta_holdAll');
            var fld_1 = $('#firstname').attr('name')+':  '+$('#firstname').val();
            var fld_2 = $('#lastname').attr('name')+':  '+$('#lastname').val();
            var fld_3 = $('#street_number').attr('name')+':  '+$('#street_number').val();
            mytextareaFld.val(fld_1 +'\n' + fld_2 +'\n' + fld_3);
        }
    
        $('#addField').on('click', AddStuff);
    
        $('#allInfo').on('click',function(event){
            AddStuff(event);
            var $mytextareaFld = $('#ta_holdAll');
            var $outPutCount = $("#charCnt");
            var $ofText = " characters of 1000 remaining";
            var val = $mytextareaFld.val();
            var val2 = $outPutCount.text(val.length).append("<strong>"+$ofText+"</strong>");
        });
    
        $("#firstname,#lastname, #street_number").blur(AddStuff);
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given some Uploader Class, I have three modules included in it. They have each
I have an application with three modules: default , disciplines and plans . In
I have a Maven build with three modules. Module A exports a jar. Module
I have parent project parent, which has three modules like: <groupId>com.dummy.bla.bla</groupId> <artifactId>parent</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging>
I have a legacy ASP.NET/VB.NET WebSite. There several App_Code modules/code files that use types
Have three divs in a container that I want to float over a large
I have three tables. Two use a foreign key that pulls in data and
I have a series of python modules written which are held in the same
I have a multi-module maven project made up of three sub-modules: web , service
I have three modules as: one.py : def abc(): print "Heeeeeeeeeeeiiiiiioooooooooo" two.py : import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.