?
Solved

Setting the value of a text box using jQuery

Posted on 2014-11-30
3
Medium Priority
?
205 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 2000 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

Python: Series & Data Frames With Pandas

Learn the basics of Python’s pandas library of series & data frames and how we can use these tools for data manipulation.

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses

770 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