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

  • Home
  • SEARCH
  • 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 8151003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:13:57+00:00 2026-06-06T15:13:57+00:00

I have three input text boxes in my form. First one is teacher, second

  • 0

I have three input text boxes in my form.

First one is teacher, second one is grade. Now I’ve the third input text box, where i need to update the value dynamically from these two values as “(teacher)’s (X) class” using JavaScript.

Can anyone help me in writing the code?
Thanks in advance.

here is the jquery code:

<script type="text/javascript">
  $(document).ready(function(){
    $('#both').value($('#teacher').val() + "'s " + $('#grade').val());
});

  </script>

and my input tags are:

<input type="text" name="teacher_name" id="teacher" value="" style="background:#f7f6f2 url(../images/input_02.png) repeat left top;border: 0px;width: 250px;height: 10px;padding: 10px;display: block;">
<input type="text" name="teacher_name" id="grade" value="" style="background:#f7f6f2 url(../images/input_02.png) repeat left top;border: 0px;width: 250px;height: 10px;padding: 10px;display: block;">
<input type="text" name="teacher_name" id="both" value="" style="background:#f7f6f2 url(../images/input_02.png) repeat left top;border: 0px;width: 250px;height: 10px;padding: 10px;display: block;">

what are the things i need to add to make my third input field to get updated.

  • 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-06T15:14:00+00:00Added an answer on June 6, 2026 at 3:14 pm

    Use the onChange event that is triggered when an input content changes or the onBlur event that is triggered when an input lost the focus:

    function UpdateInfo()
    {
      var teacher = document.getElementById('teacher').val();
      var grade = document.getElementById('grade').val();
      var info = teacher + '\'s '+ grade + ' class';
      document.getElementById('info').value = info;
    }
    
    /* Solution 1 (onChange) */
    <input id="teacher" type="text" onChange="UpdateInfo();" />
    <input id="grade" type="text" onChange="UpdateInfo();" />
    <input id="info" type="text" />
    
    /* Solution 2 (onBlur) */
    <input id="teacher" type="text" onBlur="UpdateInfo();" />
    <input id="grade" type="text" onBlur="UpdateInfo();" />
    <input id="info" type="text" />
    

    Or using jQuery, you can bind the event at document.ready event:

    $(document).ready(function()
    {
        /*
        * binding onChange event here
        * you can replace .change with .blur
        */
        $('#teacher').change(UpdateInfo);
        $('#grade').change(UpdateInfo);
    });
    
       function UpdateInfo()
       {
         var teacher = $('#teacher').val();
         var grade = $('#grade').val();
         var info = teacher + '\'s '+ grade + ' class';
         $('#info').val(info);
       }
    
    <input id="teacher" type="text" />
    <input id="grade" type="text" />
    <input id="info" type="text" />
    

    DEMO

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

Sidebar

Related Questions

I have a form with a select box and three text input boxes. When
I have an ASP.NET form with three text inputs, one each for Work Phone,
Ok so i have a form that has three input boxes, at the moment
I have a form with three text boxes. I want to have a key
I have text input boxes. There is validation for each of the boxes using
I've got a form setup with 2 text boxes that have default values that
<form> Last Name <input name=lastname type=text/><br/> First Name <input name=firstname type=text/><br/> Middle Name <input
I have three text inputs (2 input text, 1 textarea) and a submit button
i have a HTML form, user should be able to add other text boxes
Ok i have found a solution regarding my problem. I have three text boxes

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.