Solved

Setting the value of a text box using jQuery

Posted on 2014-11-30
3
202 Views
Last Modified: 2014-11-30
I have the following code:

        $(document).on('change', '#repeaterContainer select', function () {
            if ($(this).attr('targetcontrolid') == "tbShippingInstructions") {
                alert(this.value);
            }
        });

Open in new window


Works great. In trying to set this.value to a textbox, I'm trying this:

       $(document).on('change', '#repeaterContainer select', function () {
            if ($(this).attr('targetcontrolid') == "tbShippingInstructions") {
                var x = this.value;
                $('#tbShippingInstructions').val(x);
            }
        });

Open in new window


This doesn't work. how do I set the value of a text box names tbShippingInstructions to this.value??
0
Comment
Question by:Mike Miller
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40472650
       $(document).on('change', '#repeaterContainer select', function () {
            if ($(this).attr('targetcontrolid') == "tbShippingInstructions") {
                var x = $(this).val();
                $('#tbShippingInstructions').val(x);
            }
        });

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40472659
       $(document).on('change', '#repeaterContainer select', function () {
            if ($(this).attr('targetcontrolid') == "tbShippingInstructions") {
                var x = $(this).val();
                $(':text[name*=tbShippingInstructions]').val(x); // name attribute
            }
        });

Open in new window

0
 

Author Closing Comment

by:Mike Miller
ID: 40472692
Perfect, thanks!
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question