Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

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

Vim Reference Guide

Vim is a powerful text editor favored by many sysadmins and developers - here are some commands that you'll want to keep in your back pocket!

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
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…

670 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