表单特效-点击左侧选项选入右侧选择框

<html>
<head>
<title>中国站长天空-网页特效-表单特效-点击左侧选项选入右侧选择框</title>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
<!--把下面代码加到<body>与</body>之间-->
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function moveOver()
{
var boxLength = document.choiceForm.choiceBox.length;
var selectedItem = document.choiceForm.available.selectedIndex;
var selectedText = document.choiceForm.available.options[selectedItem].text;
var selectedValue = document.choiceForm.available.options[selectedItem].value;
var i;
var isNew = true;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
thisitem = document.choiceForm.choiceBox.options[i].text;
if (thisitem == selectedText) {
isNew = false;
break;
}
}
}
if (isNew) {
newoption = new Option(selectedText, selectedValue, false, false);
document.choiceForm.choiceBox.options[boxLength] = newoption;
}
document.choiceForm.available.selectedIndex=-1;
}
function removeMe() {
var boxLength = document.choiceForm.choiceBox.length;
arrSelected = new Array();
var count = 0;
for (i = 0; i < boxLength; i++) {
if (document.choiceForm.choiceBox.options[i].selected) {
arrSelected[count] = document.choiceForm.choiceBox.options[i].value;
}
count++;
}
var x;
for (i = 0; i < boxLength; i++) {
for (x = 0; x < arrSelected.length; x++) {
if (document.choiceForm.choiceBox.options[i].value == arrSelected[x]) {
document.choiceForm.choiceBox.options[i] = null;
}
}
boxLength = document.choiceForm.choiceBox.length;
}
}
function saveMe() {
var strValues = "";
var boxLength = document.choiceForm.choiceBox.length;
var count = 0;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
if (count == 0) {
strValues = document.choiceForm.choiceBox.options[i].value;
}
else {
strValues = strValues + "," + document.choiceForm.choiceBox.options[i].value;
}
count++;
}
}
if (strValues.length == 0) {
alert("您没有选择任何内容");
}
else {
alert("您选择的内容如下:/r/n"+"第" + strValues+"条");
}
}
// End -->
</script>
<form name="choiceForm">
<table border=0>
<tr>
<td valign="top" width=175>
<div align="center">可选内容:<br>
<select name="available" size=10 οnchange="moveOver();">
<option value="1">内容一</option>
<option value="2">内容二</option>
<option value="3">内容三</option>
<option value="4">内容四</option>
<option value="5">内容五</option>
<option value="6">内容六</option>
<option value="7">内容七</option>
<option value="8">内容八</option>
<option value="9">内容九</option>
<option value="10">内容十</option>
</select>
</div>
</td>
<td valign="top">
<div align="center">你的选择:<br>
<select multiple name="choiceBox" style="width:150;" size="10">
</select>
</div>
</td>
</tr>
<tr>
<td colspan=2 height=10>
<div align="center">
<input type="button" value="删除" οnclick="removeMe();">
<input type="button" value="结果" οnclick="saveMe();">
</div>
</td>
</tr>
</table>
</form>
</body>
</html>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用vxe-table的selection-config配置项来实现表单中多个复选功能。具体步骤如下: 1. 在表格的columns中添加一个type为selection的列,用于显示复选。 2. 在表格的props中设置selection-config属性,用于配置复选的相关参数,例如选中的行数据、选中的key值等。 3. 在表格的methods中添加一个handleSelectionChange方法,用于处理复选选中状态的变化。 下面是一个示例代码: ```html <template> <vxe-table :data="tableData" :columns="tableColumns" :selection-config="selectionConfig" @selection-change="handleSelectionChange"> </vxe-table> </template> <script> export default { data() { return { tableData: [ { id: 1, name: 'John', age: 20, gender: 'Male' }, { id: 2, name: 'Mary', age: 25, gender: 'Female' }, { id: 3, name: 'Tom', age: 30, gender: 'Male' } ], tableColumns: [ { type: 'selection', width: 60 }, { field: 'id', title: 'ID', width: 80 }, { field: 'name', title: 'Name', width: 120 }, { field: 'age', title: 'Age', width: 80 }, { field: 'gender', title: 'Gender', width: 100 } ], selectionConfig: { checkField: 'selected', checkMethod: (params) => { return params.row.selected }, checkAllMethod: (params) => { return params.rows.every(row => row.selected) }, checkRowKey: 'id' } } }, methods: { handleSelectionChange(selection) { console.log(selection) } } } </script> ``` 在上面的示例代码中,我们在tableColumns中添加了一个type为selection的列,用于显示复选。在selectionConfig中配置了复选的相关参数,例如选中的行数据、选中的key值等。在methods中添加了一个handleSelectionChange方法,用于处理复选选中状态的变化。当用户选中或取消选中某一行数据时,handleSelectionChange方法会被调用,并将选中的行数据作为参数传入。我们可以在该方法中处理选中状态的变化,例如将选中的行数据保存到一个数组中,或者将选中的行数据发送到后台进行处理。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值