0

I am trying to auto select an option in the parent window based on the text search in the pop-up window. Using typeahead I am only able to search on the text value, not its ID so I need to compare that way.

 //Parent Window
<form>
<select name="recipient_id" id="recipient_id">
    <option value="">----</option>
    ...
    ...
    ...
</select> <a href="javascript://" onClick="window.open(url,'_pop','width=500,height=400,status=0,directory=0,menubar=0,scrollbars=1'); return false;">Search By Name/Company</a>
</form>

//Search Window
<form id="form-attendee" name="form-attendee">
<input class="js-typeahead-attendee" id="js-typeahead-attendee" name="attendee" type="search" placeholder="Search" autocomplete="off">

 <button type="submit">
    <i class="typeahead__search-icon"></i>
 </button>
</form>
    <script>
    $(document).ready(function() {
               $("#form-attendee").submit(function() {
                    var recipientID = window.opener.$("#recipient_id");
                    $(recipientID).find("option[text='" + $("#js-typeahead-attendee").val() + "']").attr("selected", true);
                    self.close();
               });
           });

//Typeahead code here
    </script>

Used this as an example and while I'm not getting an error the parent window is not updating.

You can test this out on http://chemoutsourcing.com/test.php. Click the link on this page will bring a pop up that allows you to search for the names in the parent window drop down list.

Community
  • 1
  • 1
justacoder
  • 2,684
  • 6
  • 47
  • 78
  • Can you create a plunker http://plnkr.co to demonstrate? – guest271314 Jul 08 '16 at 03:05
  • I added a link above that you can test my work on. – justacoder Jul 09 '16 at 15:12
  • ` – guest271314 Jul 09 '16 at 15:24
  • Nice idea but it didn't take. – justacoder Jul 10 '16 at 03:28
  • You can try using `MessageChannel`, `SharedWorker`, or `localStorage`, see http://stackoverflow.com/questions/33645685/how-to-clear-the-contents-of-an-iframe-from-another-iframe/ , http://stackoverflow.com/questions/36146595/can-we-refer-to-javascript-variables-across-webpages-in-a-browser-session , http://stackoverflow.com/questions/36190731/cleartimeout-set-in-another-tab/ – guest271314 Jul 10 '16 at 03:34

0 Answers0