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.