Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2015-02-13
2
Medium Priority
?
177 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 44

Accepted Solution

by:
Chris Stanyon earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

782 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