Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
links not working 2 25
converting document.write() to innerHTML 7 44
arrays and radio buttons 10 36
[form-control] Retain values after a POST action 21 31
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.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
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 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 …

713 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