Good day, hello.
This is what day I go with FancyBox and how I can not understand how to transfer the values from the modal window to the page from where the form was called.
The essence of the task is that there is a page on which the city is chosen. When clicking on choose the city swallows the modal window, where you need to choose the city from the list by putting a tick (the option can be multiple), and then there is a button to select . When clicking on the Select button – the modal window should be hidden and on the page instead of the inscription choose the city – is replaced by the city selected from the list.
On the /index.php page, a modal window is called,
HTML:
& lt; div class = "bl_categoty" & gt;
& lt; div class = "choice_category" & gt; choose city & lt; / div & gt;
& lt; div & gt;
Here JS:
$ (". Choice_category"). FancyBox ({
'Padding': 6,
'href': '/ modal / categories.php',
// Events When closing the form applies.
BeforeClose: Function () {
Console.log ("Form closed");
$ (". bl_categoty .value_heading"). Empty (). Text ("City");
}
});
Modal window located in /Modal/categories.php. This page contains a list of cities and the button to select . If you need to click on it that the data is transferred to the /index.php page and stood in .choice_category. JS page / modal/categories.php page below:
$ (". action_category"). Click (Function (EVENT) {
// Value_Heading should be the selected city. - Not applicable
$ (". bl_categoty .value_heading"). Empty (). Text ("City");
parent.jquery.fancybox.close (); // Event is triggered
// Not applicable
$ ('. Choice_category'). FancyBox ({
BeforeClose: Function () {
Console.log ("*******************");
$ (". bl_categoty .value_heading"). Empty (). Text ("City");
}
});
});
How can I transfer the parameters from the modal window to the page /index.php
Thanks in advance for the answer. I would be very grateful for any help.
Answer 1, Authority 100%
Decided the task of
$ (". action_category"). Click (Function (EVENT) {
var category = parent.document.getelementByid ("Category_ID");
Category.Value = "Medved"
parent.jquery.fancybox.close ();
});
Answer 2
Your answer can be written as follows:
parent. $ ('# Category_id'). Val ('Medved');