<script type="text/javascript">
      	
$(document).ready(function() {
    function fetchElementIdList()
    {
        var idlanguage          = document.dataform.idlanguage.value;
        var idmenu_item_types   = document.dataform.idmenu_item_types.value;

        document.getElementById("idelement").innerHTML = "";

        if(idlanguage > 0 && idmenu_item_types > 0)
            {
                var ajax_url            = "/admin/get_json_data_for_menu/"+idmenu_item_types+"/"+idlanguage;
                /*
                $.getJSON(ajax_url, function(data) {
                            document.getElementById("idelement").innerHTML = "";
                            $.each( data, function(i, n){
                                    $("#idelement").append("<option value='"+i+"'>"+i+" - "+n+"</option>")
                            });
                });*/
                $.post(ajax_url, null, function(data, textStatus) {
                            document.getElementById("idelement").innerHTML = "";
                            $.each( data, function(i, n){
                                    $("#idelement").append("<option value='"+i+"'>"+i+" - "+n+"</option>")
                            });
                }, "json");

            }
    };

    $("#title").blur(function(){
        fetchElementIdList();
    });
    $("#idlanguage").change(function(){
        fetchElementIdList();
    });
    $("#idmenu_item_types").change(function(){
        fetchElementIdList();
    });

 });
</script>   


<h2><?= ucfirst($this->localization['dodaj_pozycje_menu']);?>:</h2>
<table>
<?php
	if(isset($idparent)){
		echo form_open('admin/add_menu_item/'.$idmenus.'/'.$idparent, array('name' => 'dataform'));
	}else{
		echo form_open('admin/add_menu_item/'.$idmenus, array('name' => 'dataform'));
	}
		echo '<tr><td>'.ucfirst($this->localization['nazwa']).': </td><td>'.form_input(array('name'=>'title', 'size'=>'50')).'</td></tr>';
		$js = 'id="idlanguage"';
		echo '<tr><td>'.ucfirst($this->localization['jezyk']).': </td><td>'.form_dropdown('idlanguage', $languages, 'large', $js).'</td></tr>';//
		$js = 'id="idmenu_item_types"';
		echo '<tr><td>'.ucfirst($this->localization['kategoria']).': </td><td>'.form_dropdown('idmenu_item_types', $menu_item_types, 'large', $js).'</td></tr>';//
		$js = 'id="idelement"';
		echo '<tr><td>'.ucfirst($this->localization['idelement']).': </td><td>'.form_dropdown('idelement', array(), 'large', $js).'</td></tr>';
		echo '<tr><td>URL: </td><td>'.form_input(array('name'=>'friendlyurl', 'size'=>'50')).'</td></tr>';
		echo '<tr><td>'.ucfirst($this->localization['aktywny']).': </td><td>'.form_checkbox('active', '1', TRUE).'</td></tr>';//
		echo '<tr><td></td><td>'.form_submit('submit', ucfirst($this->localization['wyslij'])).'</td></tr>';
	echo form_close();
?>
</table>