how to call the controller from the view In MVC model Framework in PHP Posted March 8, 2013 How to access or call the controller from the view page on change action of a drop down here my sample view page <?php //TO DO require_once __SITE_PATH . '/libs/form_handler.php'; // require_once __SITE_PATH . '/app/views/settings/redirect.php'; ?> <?php if (!empty($pagefields)) { $combotype = $pagefields['combotype']; }else { $combotype = ''; } $form = new lscform(); $form->openForm(array('action' => '', 'name' => 'addSettingsForm')); $form->addInline('<br />'); $form->addLabel('Combo Type', array('for' => 'Combo Type ', 'style' => 'float: left; width: 10em; margin-right: 1em;')); $form->openSelect(array('name' => 'combotype', 'id' => 'combotype', 'onchange' => 'getIPL(this.value)')); $form->addOption('Select the value',array('value'=>0)); foreach ($data as $value) { if ($value['id']==$combotype) { $form->addOption($value['type'],array('value'=>$value['id'] ,'selected'=>'selected' )); }else { $form->addOption($value['type'],array('value'=>$value['id'] )); } } $form->closeSelect(); $form->addInline('<br/>'); $form->closeForm(); //echo '<div style="border: 1px solid darkgrey; text-align: center; width:430px;">'; echo $form; //echo '</div>'; ?> <script src ="<?php echo __SITE_PATH;?>/styles/js/jquery.min.js"></script> <script type="text/javascript"> function getIPL(id) { var url = location.href; var pathname = location.pathname; var index1 = url.indexOf(pathname); var index2 = url.indexOf("/", index1 + 1); var baseLocalUrl = url.substr(0, index2); baseLocalUrl = baseLocalUrl + "/"; var url = "settings/Display"; // window.location.href=url ; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("combotype").innerHTML=xmlhttp.responseText; } } queryString = "?id="+id; xmlhttp.open("GET", url+queryString , false); xmlhttp.send(null); } </script> <?php
how to call the controller from the view In MVC model Framework
in PHP
Posted
How to access or call the controller from the view page on change action of a drop down here my sample view page
<?php
//TO DO
require_once __SITE_PATH . '/libs/form_handler.php';
// require_once __SITE_PATH . '/app/views/settings/redirect.php';
?>
<?php
if (!empty($pagefields))
{
$combotype = $pagefields['combotype'];
}else
{
$combotype = '';
}
$form = new lscform();
$form->openForm(array('action' => '', 'name' => 'addSettingsForm'));
$form->addInline('<br />');
$form->addLabel('Combo Type', array('for' => 'Combo Type ', 'style' => 'float: left; width: 10em; margin-right: 1em;'));
$form->openSelect(array('name' => 'combotype', 'id' => 'combotype', 'onchange' => 'getIPL(this.value)'));
$form->addOption('Select the value',array('value'=>0));
foreach ($data as $value)
{
if ($value['id']==$combotype)
{
$form->addOption($value['type'],array('value'=>$value['id'] ,'selected'=>'selected' ));
}else
{
$form->addOption($value['type'],array('value'=>$value['id'] ));
}
}
$form->closeSelect();
$form->addInline('<br/>');
$form->closeForm();
//echo '<div style="border: 1px solid darkgrey; text-align: center; width:430px;">';
echo $form;
//echo '</div>';
?>
<script src ="<?php echo __SITE_PATH;?>/styles/js/jquery.min.js"></script>
<script type="text/javascript">
function getIPL(id)
{
var url = location.href;
var pathname = location.pathname;
var index1 = url.indexOf(pathname);
var index2 = url.indexOf("/", index1 + 1);
var baseLocalUrl = url.substr(0, index2);
baseLocalUrl = baseLocalUrl + "/";
var url = "settings/Display";
// window.location.href=url ;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("combotype").innerHTML=xmlhttp.responseText;
}
}
queryString = "?id="+id;
xmlhttp.open("GET", url+queryString , false);
xmlhttp.send(null);
}
</script>
<?php