Solved

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

Posted on 2015-02-13
2
147 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 43

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

867 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