左右选择框


<!-- 把如下代码加入<body>区域中 -->
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
sortitems = 1;  // Automatically sort items within lists? (1 or 0)

 function move(fbox,tbox) {
  for(var i=0; i<fbox.options.length; i++) {
    if(fbox.options[i].selected && fbox.options[i].value != "") {
    var no = new Option();
    no.value = fbox.options[i].value;
    no.text = fbox.options[i].text;
    tbox.options[tbox.options.length] = no;
    fbox.options[i].value = "";
    fbox.options[i].text = "";
       }
  }
 BumpUp(fbox);
 if (sortitems) SortD(tbox);
 }

   function moveall(fbox,tbox) {
  for(var i=0; i<fbox.options.length; i++) {
    if(fbox.options[i].value != "") {
    var no = new Option();
    no.value = fbox.options[i].value;
    no.text = fbox.options[i].text;
    tbox.options[tbox.options.length] = no;
    fbox.options[i].value = "";
    fbox.options[i].text = "";
       }
  }
 BumpUp(fbox);
 if (sortitems) SortD(tbox);
 }


 function BumpUp(box)  {
  for(var i=0; i<box.options.length; i++) {
    if(box.options[i].value == "")  {
       for(var j=i; j<box.options.length-1; j++)  {
       box.options[j].value = box.options[j+1].value;
       box.options[j].text = box.options[j+1].text;
       }
    var ln = i;
    break;
       }
  }
  if(ln < box.options.length)  {
  box.options.length -= 1;
  BumpUp(box);
     }
 }

function SortD(box)  {
 var temp_opts = new Array();
 var temp = new Object();
 for(var i=0; i<box.options.length; i++)  {
 temp_opts[i] = box.options[i];
 }

 for(var x=0; x<temp_opts.length-1; x++)  {
   for(var y=(x+1); y<temp_opts.length; y++)  {
     if(temp_opts[x].text > temp_opts[y].text)  {
     temp = temp_opts[x].text;
     temp_opts[x].text = temp_opts[y].text;
     temp_opts[y].text = temp;
     temp = temp_opts[x].value;
     temp_opts[x].value = temp_opts[y].value;
     temp_opts[y].value = temp;
        }
      }
 }

 for(var i=0; i<box.options.length; i++)  {
 box.options[i].value = temp_opts[i].value;
 box.options[i].text = temp_opts[i].text;
    }
}

 


 
// End -->
</script>

<form ACTION="" METHOD="POST">
<table border="0">
<tr>
<td><select multiple size="5" name="list1" style="width:250px">
<option value="11"> item 1.1 </option>
<option value="12"> item 1.2 </option>
<option value="13"> item 1.3 </option>
</select></td>
<td>
<input type="button" value="   >   " οnclick="move(this.form.list1,this.form.list2)" name="B1"><br>
<input type="button" value="   <   " οnclick="move(this.form.list2,this.form.list1)" name="B2"><br>

<input type="button" value="   >>   " οnclick="moveall(this.form.list1,this.form.list2)" name="B3"><br>
<input type="button" value="   <<   " οnclick="moveall(this.form.list2,this.form.list1)" name="B4">
</td>
<td><select multiple size="5" name="list2" style="width:250px">
<option value="21"> item 2.1 </option>
<option value="22"> item 2.2 </option>
<option value="23"> item 2.3 </option>
</select></td>


</tr>
</table>
</form>


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的日期选择的 Vue 3 组件示例: ```vue <template> <div class="date-picker"> <input type="text" v-model="selectedDate" @focus="showDatePicker" /> <div v-if="show" class="date-picker-container"> <div class="calendar-header"> <div class="calendar-prev" @click="prevMonth"><</div> <div class="calendar-title">{{ currentMonth }}</div> <div class="calendar-next" @click="nextMonth">></div> </div> <div class="calendar-body"> <div class="calendar-row"> <div v-for="day in daysOfWeek" class="calendar-cell day-header"> {{ day }} </div> </div> <div v-for="week in weeks" class="calendar-row"> <div v-for="day in week" :class="getDayClasses(day)" @click="selectDate(day)"> {{ day ? day.getDate() : '' }} </div> </div> </div> </div> </div> </template> <script> import { ref, computed } from 'vue'; export default { name: 'DatePicker', setup() { const selectedDate = ref(''); const show = ref(false); const currentDate = new Date(); let currentMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1); const daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; const weeks = computed(() => { const month = currentMonth.getMonth(); const year = currentMonth.getFullYear(); const firstDayOfMonth = new Date(year, month, 1); const lastDayOfMonth = new Date(year, month + 1, 0); const daysInMonth = lastDayOfMonth.getDate(); const firstDayOfWeek = firstDayOfMonth.getDay(); const weeks = [[]]; let currentWeek = 0; for (let i = 0; i < firstDayOfWeek; i++) { weeks[currentWeek].push(null); } for (let i = 1; i <= daysInMonth; i++) { if (weeks[currentWeek].length === 7) { currentWeek++; weeks[currentWeek] = []; } weeks[currentWeek].push(new Date(year, month, i)); } for (let i = weeks[currentWeek].length; i < 7; i++) { weeks[currentWeek].push(null); } return weeks; }); const getDayClasses = (day) => { const classes = ['calendar-cell']; if (!day) return classes; if (day.getMonth() !== currentMonth.getMonth()) { classes.push('disabled'); } if (day.toDateString() === selectedDate.value.toDateString()) { classes.push('selected'); } return classes; }; const selectDate = (day) => { if (!day || day.getMonth() !== currentMonth.getMonth()) return; selectedDate.value = day; show.value = false; }; const showDatePicker = () => { show.value = true; }; const prevMonth = () => { currentMonth = new Date(currentMonth.getFullYear(), currentMonth.getMonth() - 1, 1); }; const nextMonth = () => { currentMonth = new Date(currentMonth.getFullYear(), currentMonth.getMonth() + 1, 1); }; return { selectedDate, show, currentDate, currentMonth, daysOfWeek, weeks, getDayClasses, selectDate, showDatePicker, prevMonth, nextMonth, }; }, }; </script> <style scoped> .date-picker { position: relative; } .date-picker-container { position: absolute; top: 30px; left: 0; padding: 10px; border: 1px solid #ccc; background-color: #fff; } .calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; } .calendar-prev, .calendar-next { font-size: 20px; cursor: pointer; } .calendar-title { font-weight: bold; } .calendar-row { display: flex; justify-content: space-between; margin-bottom: 10px; } .calendar-cell { width: calc(100% / 7); text-align: center; cursor: pointer; } .calendar-cell.day-header { font-weight: bold; } .calendar-cell.disabled { color: #ccc; cursor: not-allowed; } .calendar-cell.selected { background-color: #ccc; } </style> ``` 使用方法: ```vue <template> <div> <date-picker v-model="selectedDate" /> <p>Selected date: {{ selectedDate }}</p> </div> </template> <script> import DatePicker from './DatePicker.vue'; export default { name: 'App', components: { DatePicker, }, data() { return { selectedDate: '', }; }, }; </script> ``` 在上面的示例中,我们使用了 `ref` 和 `computed` 来处理组件中的状态和计算属性。我们还使用了 `v-model` 来实现日期选择的双向绑定。在样式方面,我们使用了 `scoped` 属性,将样式限制在组件内部。 该组件的功能包括: - 点击输入弹出日期选择 - 可以选择当前月份内的日期 - 选择的日期会在输入中显示 - 可以通过左右箭头切换月份 - 当前月份外的日期会被禁用并显示为灰色 - 选中的日期会高亮显示为灰色 当然,该组件还可以根据不同的需求进行进一步的定制和优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值