Solved

Click HREF from Modal Window and value appear in textbox on parent

Posted on 2015-02-13
2
145 Views
Last Modified: 2015-02-14
I have a search form in a modal window.  It returns ID values.  I want to click that href and have the ID appear in a textbox on the parent form and close the modal window.

Here is a screenshot of what i am looking to do:
http://www.screencast.com/t/tGojwtDL
0
Comment
Question by:theideabulb
2 Comments
 
LVL 42

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 40609622
OK. We'll need more info to help you out, but here's a general overview. You would bind the click() event of the link, and then set the textbox to the text inside of the link. We'd need to know the names / classes or ID or the links and the textbox.

Assume your links have a class of productID, and your textbox has an id of selectedProduct:

<a href="#" class="productID">057-10-2000</a>
<input type="text" id="selectedProduct" value="" />

Open in new window


Your jQuery would look something like this:

$('.productID').click(function(e) {
   e.preventDefault();
   $('#selectedProduct').val($(this).text());
});

Open in new window


As to how you close the modal window, that will depend on how you created it. If you use a plugin of some sort, then there's likely to be a close() method, but as I said - we'll need more info.

You can see a very simple, working demo here -> http://jsfiddle.net/ChrisStanyon/uno5b1bk/
0
 

Author Closing Comment

by:theideabulb
ID: 40609868
Bingo, worked perfectly.  Thank you!  It wasn't working at first until i moved the jQuery code to that modal window page of code.  then it worked exactly how i needed it.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 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

21 Experts available now in Live!

Get 1:1 Help Now