Solved

Setting the value of a text box using jQuery

Posted on 2014-11-30
3
195 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:mwmiller78
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:mwmiller78
ID: 40472692
Perfect, thanks!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now