<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>下拉框</title>
<link rel="stylesheet" href="application/views/<?= ADMIN_NAME ?>/inc/SelectMenu/selectmenu.css" type="text/css">
<script src="application/views/<?= ADMIN_NAME ?>/js/jquery.js"></script>
<script src="application/views/<?= ADMIN_NAME ?>/inc/SelectMenu/selectmenu.js"></script>
<script src="application/views/<?= ADMIN_NAME ?>/inc/SelectMenu/selectmenu.min.js"></script>
 <link rel="stylesheet" type="text/css" href="application/views/<?= ADMIN_NAME ?>/css/common.css" />
</head>
<body>

<select name="classid" id="btnMenu" class="select-container1"> </select>
 
</body>

<script type="text/javascript">
<?php 
		 $filedModel1=new FiledModel("filed");
         $filedId=$_GET["field_id"];
         $filedDetail=$filedModel1->selectByPk($filedId);
         $filedVal=$filedModel1->getFiledDefaultValue($filedId);	
         $selectMenuData="[";
         //$selectMenuData.="{id:'0' ,value:''}";
		foreach($filedVal as $k=>$v)
		{
			if($k==0)
				{
				    $selectMenuData.="{id:'".$v['key']."' ,value:'".$v['value']."'}";
				}else
				{
					$selectMenuData.=",{id:'".$v['key']."' ,value:'".$v['value']."'}";
				}
			
		}
		$selectMenuData.="]";
         
?>


//获取父框架的元素的默认值
var _ghyOb=$('#<?php echo $_GET["field"]?>', window.parent.document);
var selectValue="";
if(_ghyOb.val().trim()!="")
{
	selectValue=_ghyOb.val().trim();
	var temp_selectMenuData=eval ("(<?php echo $selectMenuData ?>)");
	for(var i=0;i<temp_selectMenuData.length;i++)
		{
		if(selectValue==temp_selectMenuData[i].id)
			{
		   	    $('#btnMenu').append(' <option   selected="selected">'+temp_selectMenuData[i].value+'</option>  ');
			}else
			{
				$('#btnMenu').append(' <option  >'+temp_selectMenuData[i].value+'</option>  ');	
			}
			
		}
}else
{
	$('#btnMenu').html(' <option   selected="selected">请选择</option>  ');
}

  
</script>

</html>
