21,887
社区成员
发帖
与我相关
我的任务
分享
推荐位位置:<select id="source" name="source" style="width:150px">
<option value="" selected>请选择</option>
<?php foreach ($GLOBALS['source_recommend'] as $_k=>$_v)?>
<option value="<?php echo $_k;?>"><?php echo $_v;?></option>
</select>
推荐位:<select id="position" name="position" style="width:150px">
<option value="" selected>请选择</option>
<option value="" ></option>
</select>
/*
*第一个选择框用到的数组
*/
$source_recommend = array(
'news'=>'资讯',
'topic'=>'话题',
'usershow'=>'会员秀',
'activity'=>'活动',
);
/*
*第二个选择框用到的数组
*/
$news_position = array(
'index_news_1'=>'a',
'index_news_2'=>'b',
'index_news_3'=>'c',
'index_news_4'=>'d',
'index_news_5'=>'e',
'index_news_6'=>'f',
'index_news_7'=>'g',
);
$topic_position = array(
'topic_topic_1'=>'h',
'topic_topic_2'=>'i',
);
$usershow_position = array(
'index_usershow_1'=>'j',
'index_usershow_2'=>'k',
'index_usershow_content_1'=>'l',
'usershow_usershow_1'=>'m',
'usershow_usershow_2'=>'n',
);
$activity_position = array(
'ground_activity_1'=>'p',
);
推荐位位置:
<select id="source" name="source" style="width:150px" onchange="changes(this.value)">
<option value="" selected>请选择</option>
<option value="news">资讯</option>
<option value="topic">话题</option>
<option value="usershow">会员秀</option>
<option value="activity">活动</option>
</select>
推荐位:
<div id="two">
<select id="position" name="position" style="width:150px">
<option value="" selected>请选择</option>
<option value="" ></option>
</select>
</div>
<script>
function changes(v){
var url='selectphp.php';
var date='ac=action&val='+v;
$.post(url,date,function(x){
$('#two').html(x);
})
}
</script>
<?php
if(isset($_POST['ac']) && $_POST['ac']=='action'){
$val=$_POST['val'];
$news= array(
'index_news_1'=>'a',
'index_news_2'=>'b',
'index_news_3'=>'c',
'index_news_4'=>'d',
'index_news_5'=>'e',
'index_news_6'=>'f',
'index_news_7'=>'g',
);
$topic= array(
'topic_topic_1'=>'h',
'topic_topic_2'=>'i',
);
$usershow= array(
'index_usershow_1'=>'j',
'index_usershow_2'=>'k',
'index_usershow_content_1'=>'l',
'usershow_usershow_1'=>'m',
'usershow_usershow_2'=>'n',
);
$activity= array(
'ground_activity_1'=>'p',
);
echo '<div id="two"><select id="position" name="position" style="width:150px">';
foreach($$val as $k=>$v){
echo '<option value="'.$k.'" >'.$v.'</option>';
}
echo '</select></div>';
}
?>
推荐位位置:
<select id="source" name="source" style="width:150px" onchange="changes(this.value)">
<option value="" selected>请选择</option>
<option value="news">资讯</option>
<option value="topic">话题</option>
<option value="usershow">会员秀</option>
<option value="activity">活动</option>
</select>
推荐位:
<div id="two">
<select id="position" name="position" style="width:150px">
<option value="" selected>请选择</option>
<option value="" ></option>
</select>
</div>
<script>
function changes(v){
var url='selectphp.php';
var date='ac=action&val='+v;
$.post(url,date,function(x){
$('#two').html(x);
})
}
</script>
selectphp文件
[code=PHP]
<?php
if(isset($_POST['ac']) && $_POST['ac']=='action'){
$val=$_POST['val'];
$news= array(
'index_news_1'=>'a',
'index_news_2'=>'b',
'index_news_3'=>'c',
'index_news_4'=>'d',
'index_news_5'=>'e',
'index_news_6'=>'f',
'index_news_7'=>'g',
);
$topic= array(
'topic_topic_1'=>'h',
'topic_topic_2'=>'i',
);
$usershow= array(
'index_usershow_1'=>'j',
'index_usershow_2'=>'k',
'index_usershow_content_1'=>'l',
'usershow_usershow_1'=>'m',
'usershow_usershow_2'=>'n',
);
$activity= array(
'ground_activity_1'=>'p',
);
echo '<div id="two"><select id="position" name="position" style="width:150px">';
foreach($$val as $k=>$v){
echo '<option value="'.$k.'" >'.$v.'</option>';
}
echo '</select></div>';
}
?>