I tried to pass any value from my modal window mod to the parent window, but it does not work. modalnot hideor send the value to the parent window when I click Save.
application.php
<body>
<h3 class="h3 black">Application</h3>
<form class="form-horizontal" method="post" action="admin-controller.php" name="f1">
<input type="text" name="p_name" id="n1" >
<?php
include 'includes/calendar.php';
$calendar = new Calendar();
echo $calendar->show();
?>
</form>
</body>
<script src="https://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0 /jquery.validate.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script type="text/javascript">
function post_value(){
window.opener.document.f1.p_name = document.myform.skill_id_t.value;
$('#modal_1').modal('hide');
}
</script>
calendar.php
<?php
class Calendar {
public function show() {
$html .=$this->_showDay($someValues);
}
private function _showDay($cellNumber){
$html = '<td id="' . $this->currentDate . '" class="td-top-text ' . $classNameOne . $classNameTwo . '">';
$html .= '<input type="radio" data-toggle="modal" data-target="#modal_1" name="schedule_id" value="'. $shedule_id.'">';
$html .=$this->_singleModal();
$html .= '</td>';
return $html;
}
public function _singleModal(){
$html = '<form name="myform" method="post" action="">';
$html .= '<div class="modal fade" id="modal_1" role="dialog">';
$html .= '<div class="modal-dialog">';
$html .= '<div class="modal-content">';
$html .= '<div class="modal-header">';
$html .= '<button type="button" class="close" data-dismiss="modal">×</button>';
$html .= '<h4 class="modal-title bold cyan">Sign Up (Single)</h4>';
$html .= ' </div>';
$html .= '<div class="modal-body">';
$html .= '<input name="skill_id_t" type="text">';
$html .= '</div>';
$html .= '<div class="modal-footer">';
$html .= '<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>';
$html .= '<input onclick="post_value();" id="save" type="button" name="save-details" value="Save">';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</form>';
return $html;
}
}
I read other messages and, according to them, the problem may be javascriptbecause I can not use data-target="#modal_1"with javascript, so I tried to delete targetand just add onclicka function call to my <input name="schedule_id">execute $(#modal_1).modal('show');, but still does $(#modal_1).modal('hide');not work.
I also had a tag phpbecause, according to other posts, I need to include javascriptin mine php( calendar.php), not mineapplication.php
Edit
, Save
TypeError: openener null
, window.opener...,
:
js :
$(function() {
$('#btnLaunch_1').click(function() {
$('#modal_1').modal('show');
});
$('#btnSave_1').click(function() {
opener.document.f1.p_name = document.myform.skill_id_t.value;
$('#modal_1').modal('hide');
});
$('#cancel_1').click(function() {
$('#modal_1').modal('hide');
});
});
, data-target, , data-dismiss. , opener.document.f1.p_name = document.myform.skill_id_t.value; - , . ...opener is null
, =/II .