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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:07:18+00:00 2026-06-17T21:07:18+00:00

My question is similar to this: How to get textbox value into label using

  • 0

My question is similar to this: How to get textbox value into label using jquery, but I’m trying to do opposite: I’m trying to get the value of a label into a into a textbox. I thought it’d be a simple matter of switching the elements in the code, but that’s not the case, apparently. I also did take a look at some of the questions presented in the “Questions that may already have your answer” section below my title, but didn’t find something that helped me (maybe the solution was in one of them, but I just didn’t understand it…).

Here’s my table’s html:

<table id="tblBranchDetails">
    <tr>
        <td width="120px">Branch:</td>
            <td id="branchName" class="branchData">
                <label id="lblBranchName"></label>
                <input type="text" id="txtBranchName" />
            </td>...

As the author of the post above noted, this doesn’t work:

$('input#hdnBranchName').val() = $('label#lblBranchName').text();

I’ve tried these:

$('input#txtBranchName').html($('label#lblBranchName').val());
$('input#txtBranchName').text($('label#lblBranchName').val());

Neither of those worked. So I tried to see if maybe I wasn’t selecting the textbox correctly:

$('table#tblBranchDetails input#txtBranchName').html($('label#lblBranchName').val());
$('table#tblBranchDetails input#txtBranchName').text($('label#lblBranchName').val());

But neither of those worked either.

How do I do this, and as a matter of learning more: why doesn’t what I would assume to be the obvious method work?

Thanks!

  • 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-17T21:07:20+00:00Added an answer on June 17, 2026 at 9:07 pm

    have a look to the docs..

    A string of text or an array of strings corresponding to the value of each matched element to set as selected/checked.
    This method is typically used to set the values of form fields.

    try this

    $('input#hdnBranchName').val($('label#lblBranchName').text());
    

    val() is to get the selected input value… where as val('') is to set.. this sets empty to the selected input field

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

Sidebar

Related Questions

I've asked a question similar to this but thought I would ask a more
My question is very similar to this topic . I'm trying to use jquery,
My question is similar to this question but I'm not using code igniter. I'm
This is a similar question as How to get the common name for a
Mainly this is a question about how to get a similar behaviour as java
I have asked a question similar to this in the past but this is
I found this similar question here , but this is really old. Was it
my question is similar to this one , but I don't want to use
I have a question similar to this question but it is MonoTouch specific. When
I've already asked question similar to this some time ago, I thought I solved

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.