本帖最后由 fantom 于 2009-2-23 16:49 编辑
第一步:
修改程序
打开cp.profile.php
//生日:年- $birthyeayhtml = '';
- $nowy = sgmdate('Y');
- for ($i=0; $i<100; $i++) {
- $they = $nowy - $i;
- $selectstr = $they == $space['birthyear']?' selected':'';
- $birthyeayhtml .= "<option value="$they"$selectstr>$they</option>";
- }
- //生日:月
- $birthmonthhtml = '';
- for ($i=1; $i<13; $i++) {
- $selectstr = $i == $space['birthmonth']?' selected':'';
- $birthmonthhtml .= "<option value="$i"$selectstr>$i</option>";
- }
- //生日:日
- $birthdayhtml = '';
- for ($i=1; $i<32; $i++) {
- $selectstr = $i == $space['birthday']?' selected':'';
- $birthdayhtml .= "<option value="$i"$selectstr>$i</option>";
- }
复制代码 注释掉
第二步:
修改模板
打开cp_profile.htm
(1)- <select id="birthyear" name="birthyear">
- <option value="0">无</option>
- $birthyeayhtml
- </select> 年
- <select id="birthmonth" name="birthmonth">
- <option value="0">无</option>
- $birthmonthhtml
- </select> 月
- <select id="birthday" name="birthday">
- <option value="0">无</option>
- $birthdayhtml
- </select> 日
复制代码 改成- <select name=birthyear size=1 onchange="showbirthmonth();showbirthday()">
- <script>
- var birthyearbegin=1900,birthyearend=2005;
- <!--{if $space[birthyear]}-->
- document.write("<option value=$space[birthyear] selected>$space[birthyear]</option>")
- <!--{else}-->
- document.write("<option value=''selected>年份</option>")
- <!--{/if}-->
- for(var i=birthyearbegin;i<=birthyearend;i++){
- document.write ("<option value="+i+">"+i+"</option>")
- }
- </script>
- </select> 年
- <select id="birthmonth" name="birthmonth" onchange="showbirthday();">
- <!--{if $space['birthmonth']}-->
- <option value="$space[birthmonth]" selected>$space[birthmonth]</option>
- <!--{else}-->
- <option value="">月份</option>
- <!--{/if}-->
- </select> 月
- <select id="birthday" name="birthday">
- <!--{if $space[birthday]}-->
- <option value="$space[birthday]" selected>$space[birthday]</option>
- <!--{else}-->
- <option value=''>日期</option>
- <!--{/if}-->
- </select>日
复制代码 (2)- <form method="post" action="cp.php?ac=profile&ref" class="c_form" >
复制代码 改成- <form method="post" action="cp.php?ac=profile&ref" class="c_form" name="f1">
复制代码 (3)- <script>
- var elbirthyear=eval(document.f1.birthyear)
- var elbirthmonth=eval(document.f1.birthmonth);
- function showbirthmonth(){
- if(elbirthyear.value!=""){
- for(var i=0;i<12;i++){
- elbirthmonth.options.add(new Option(i+1, i+1));
- }
- }
- }
- function showbirthday(){
- var elbirthday=eval(document.f1.birthday);
- if(elbirthmonth.value!="" && elbirthyear.value!=""){
- elbirthday.length=0;
- for(var i=0;i<28;i++){
- elbirthday.options.add(new Option(i+1, i+1));
- }
- if(elbirthmonth.value!="2"){
- elbirthday.options.add(new Option(29, 29));
- elbirthday.options.add(new Option(30, 30));
- }
- switch(elbirthmonth.value){
- case "1":
- case "3":
- case "5":
- case "7":
- case "8":
- case "10":
- case "12":{
- elbirthday.options.add(new Option(31, 31));
- }
- case "2":{
- var nbirthyear=elbirthyear.value;
- if(nbirthyear%400==0 || nbirthyear%4==0 && nbirthyear%100!=0)elbirthday.options.add(new Option(29, 29));
- }
- }
- }
- }
- </script>
复制代码 还有个问题就是重新选择时
已选择的无法取消(有重复选项但不影响结果)
本人太差只能做到这种程度 |