Solved

Setting the value of a text box using jQuery

Posted on 2014-11-30
3
203 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…

707 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