select 左右选择器!!!

<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!doctype html>
< html >
     < head >
         < title >Site Management Centre</ title >
         < meta http-equiv = "Content-Type" content = "text/html;charset=utf-8" />
             < script type = "text/javascript" language = "javascript" >  
    function moveItem(dest, source)  
    {  
         var dest   = ( typeof dest == "string" ? document.getElementById(dest): dest );  
         var source = ( typeof source  == "string" ? document.getElementById(source) : source );  
    
         if( source.tagName.toLowerCase() != "select" || dest.tagName.toLowerCase() != "select" )  
             return;  
    
         for ( index=source.length - 1; index >= 0; index-- ) {  
             if ( source[index].selected ) {  
                 dest.length++;                      
                 dest[dest.length-1].id    = source[index].id;  
                 dest[dest.length-1].value = source[index].value;  
                 dest[dest.length-1].text  = source[index].text;  
                 source[index] = null;  
             }  
         }  
     }  
      
</ script >  
</ head >
< body >
< table width = "20%" border = "1" cellpadding = "0" cellspacing = "0" align = "center" >  
         < tr >  
             < td width = "10%" >          
                 < select size = "10" multiple = "multiple" id = "left" ondblclick = "moveItem(right,this)" style = "width:120px; " >  
                     < option value = "def7" >ListItem1</ option >  
                     < option value = "abcd6" >ListItem2</ option >  
                 </ select >  
             </ td >  
             < td width = "3%" >  
                 < input type = "button" value=" >> " name="btnRight" onclick="moveItem(right,left)" />                
                 < input type = "button" value = " << " onclick = "moveItem(left,right)" id = "btn" name = "btnLeft" />  
             </ td >  
             < td width = "10%" >  
            
                 < select size = "10" multiple = "multiple" id = "right" ondblclick = "moveItem(left,this)" style = "width:120px; " >  
                 </ select >  
             </ td >  
         </ tr >  
     </ table >  
     </ body >
      
</ html >
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个使用 Vue3 的语法实现月份选择器的示例代码: ```vue <template> <div class="month-picker"> <input type="text" v-model="selectedMonth" readonly @click="showPicker" /> <div class="picker" v-show="isPickerVisible"> <div class="header"> <button @click="previousYear"><<</button> <button @click="previousMonth"><</button> <span>{{ currentYear }} 年 {{ currentMonth }} 月</span> <button @click="nextMonth">></button> <button @click="nextYear">>></button> </div> <div class="body"> <div class="month" v-for="(month, index) in months" :key="index" @click="selectMonth(month)"> {{ month }} </div> </div> </div> </div> </template> <script> import { ref, computed } from 'vue'; export default { name: 'MonthPicker', setup() { const selectedMonth = ref(''); const isPickerVisible = ref(false); const currentYear = ref(new Date().getFullYear()); const currentMonth = ref(new Date().getMonth() + 1); const months = computed(() => { const result = []; for (let i = 1; i <= 12; i++) { result.push(`${i} 月`); } return result; }); const showPicker = () => { isPickerVisible.value = true; }; const hidePicker = () => { isPickerVisible.value = false; }; const previousMonth = () => { if (currentMonth.value === 1) { currentMonth.value = 12; currentYear.value -= 1; } else { currentMonth.value -= 1; } }; const nextMonth = () => { if (currentMonth.value === 12) { currentMonth.value = 1; currentYear.value += 1; } else { currentMonth.value += 1; } }; const previousYear = () => { currentYear.value -= 1; }; const nextYear = () => { currentYear.value += 1; }; const selectMonth = (month) => { selectedMonth.value = month; hidePicker(); }; return { selectedMonth, isPickerVisible, currentYear, currentMonth, months, showPicker, hidePicker, previousMonth, nextMonth, previousYear, nextYear, selectMonth, }; }, }; </script> <style scoped> .month-picker { position: relative; } .picker { position: absolute; top: 100%; left: 0; z-index: 1; background-color: #fff; border: 1px solid #ccc; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); } .header { display: flex; justify-content: space-between; align-items: center; padding: 8px; background-color: #f5f5f5; } .header button { border: none; background-color: transparent; font-size: 14px; cursor: pointer; } .body { display: flex; flex-wrap: wrap; padding: 8px; } .month { flex-basis: 25%; padding: 8px; text-align: center; cursor: pointer; } .month:hover { background-color: #f5f5f5; } </style> ``` 这个月份选择器组件包含一个输入框和一个下拉框,用户可以通过点击输入框来显示下拉框,从而选择一个月份。下拉框显示了当前年份和月份,以及所有的月份选项。用户可以通过点击月份选项来选择一个月份,选择后下拉框会自动隐藏并将选择的月份显示在输入框中。用户还可以通过左右箭头按钮来切换年份和月份。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值