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 7594121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:20:09+00:00 2026-05-30T21:20:09+00:00

I have two textareas. When the user clicks a text link, ie Add to

  • 0

I have two textareas. When the user clicks a text link, ie “Add to Cart”, how would I get the values of both textareas to be pasted into a third textarea, separated by a delimiter like ” — “, and finally for a new page to load once the function is complete?

The code I have so far is:

JS:

$('#addtocart').click(function() {
var text1 = $("#inputA").val();
var text2 = $("#inputB").val();
var text3 = text1 + "\n--\n" + text2;
$("#personalisedmsg").val(text3);   
};

HTML:

<textarea id="inputA" class="limited" rows="6">Your top message here.</textarea><br />
<textarea id="inputB" class="limited" rows="6">Your bottom message here.</textarea><br />
<textarea id="personalisedmsg"></textarea>

<br><br>

<a id="addtocart" href="#">Add to Cart.</a>

Thanks for any help.

  • 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-05-30T21:20:11+00:00Added an answer on May 30, 2026 at 9:20 pm

    To do the text field stuff…

    var text1 = $("#textbox1").val();//textbox1 is the id value of the text area
    var text2 = $("#textbox2").val();//textbox2 is the id value of the text area
    var text3 = text1 + "\n--\n" + text2;
    $("#textbox3").val(text3);//set the next text in textbox3
    

    To load a new page doesnt make sense, what are you doing with textbox3 data before? Do you instead want to submit a form? If so, you can do like this for example (assuming only one form in document)…

    document.forms[0].submit();
    

    or to just reload a new page if you really want to then…

    window.location = 'newpage.html';//or whatever you page is called
    

    Important Note

    When you use the click handler of a link, if the link has a href property set you should ensure you are cancelling the default action (i.e. the reloading of a new page)…

    $('#addtocart').click(function(e) {
        e.preventDefault();//cancel the new page load action
    
        //rest of code here
    });
    

    Working Example

    Here is a working example

    note that after copying your JQuery code I had to add an additional close bracket ) at the end for it to run correctly

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an input form with two textareas allowing a user to type in
I have two pages, product.php and viewcart.php. When a user clicks on a button
I have two textures that are both .jpg, which represent a sky (one during
I have a textarea tag that has text I want a user to edit.
I have a form that allows the user to either upload a text file
I have two input textareas, and the second one is hidden. Is it possible
I am using jQuery validate to validate a form. I have two text boxes
I am writing a flex application and I have two Spark TextAreas. I want
I have a Django application with two models: the first one is django.contrib.auth.User and
I have two views: create and edit. Both share a strongly typed editor template

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.