我在表单上有多个“添加/删除多个选择字段”。关于如何完成两个不同的功能,我有两个问题。
如何获取放置在“添加”中的多个值(我使用MySQL进入该字段),将其解析并放入以逗号分隔的字段或电子邮件中。
我有6组这些多个选择字段。当用户选择该值并移动它以进行添加时,我希望从其他组中删除这些值,以便无法添加它们。
这是我的代码:
JS:
//GROUP 1
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$().ready(function() {
$('#add').click(function() {
return !$('#select1 option:selected').remove().appendTo('#select2');
});
$('#remove').click(function() {
return !$('#select2 option:selected').remove().appendTo('#select1');
});
});
</script>
//GROUP 2
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$().ready(function() {
$('#add2').click(function() {
return !$('#select3 option:selected').remove().appendTo('#select4');
});
$('#remove2').click(function() {
return !$('#select4 option:selected').remove().appendTo('#select3');
});
});
</script>
//GROUP 3
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$().ready(function() {
$('#add3').click(function() {
return !$('#select5 option:selected').remove().appendTo('#select6');
});
$('#remove3').click(function() {
return !$('#select6 option:selected').remove().appendTo('#select5');
});
});
</script>
//GROUP 4
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$().ready(function() {
$('#add4').click(function() {
return !$('#select7 option:selected').remove().appendTo('#select8');
});
$('#remove3').click(function() {
return !$('#select8 option:selected').remove().appendTo('#select7');
});
});
</script>
//GROUP 5
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$().ready(function() {
$('#add5').click(function() {
return !$('#select9 option:selected').remove().appendTo('#select10');
});
$('#remove5').click(function() {
return !$('#select9 option:selected').remove().appendTo('#select10');
});
});
</script>
//GROUP 6
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$().ready(function() {
$('#add6').click(function() {
return !$('#select11 option:selected').remove().appendTo('#select12');
});
$('#remove6').click(function() {
return !$('#select12 option:selected').remove().appendTo('#select11');
});
});
</script>
HTML:
//GROUP 1
<select name="select1" [] multiple class="calloutForm" id="select1" title="<? php echo $row_allUsers['submittername']; ?>">
<?php
do {
?>
<option value="<?php echo $row_allUsersDynamicList['submittername']? >"><?php echo $row_allUsersDynamicList['submittername']?></option>
<?php
} while ($row_allUsersDynamicList = mysql_fetch_assoc($allUsersDynamicList));
$rows = mysql_num_rows($allUsersDynamicList);
if($rows > 0) {
mysql_data_seek($allUsersDynamicList, 0);
$row_allUsersDynamicList = mysql_fetch_assoc($allUsersDynamicList);
}
?>
</select>
</div></td>
<td width="138" rowspan="2"><div align="center">>>></div></td>
<td width="181"><div align="left">
<select name="select2" multiple class="calloutForm" id="select2">
</select>
//GROUP 2
<td width="139"><div align="right">
<select name="select3" multiple="multiple" class="calloutForm" id="select3" title="<?php echo $row_allUsers['submittername']; ?>">
<?php
do {
?>
<option value="<?php echo $row_allUsersDynamicList['submittername']?>"><?php echo $row_allUsersDynamicList['submittername']?></option>
<?php
} while ($row_allUsersDynamicList = mysql_fetch_assoc($allUsersDynamicList));
$rows = mysql_num_rows($allUsersDynamicList);
if($rows > 0) {
mysql_data_seek($allUsersDynamicList, 0);
$row_allUsersDynamicList = mysql_fetch_assoc($allUsersDynamicList);
}
?>
</select>
</div></td>
//GROUP 3
<td width="139"><div align="right">
<select name="select5" multiple="multiple" class="calloutForm" id="select5" title="<?php echo $row_allUsers['submittername']; ?>">
<?php
do {
?>
<option value="<?php echo $row_allUsersDynamicList['submittername']?>"><?php echo $row_allUsersDynamicList['submittername']?></option>
<?php
} while ($row_allUsersDynamicList = mysql_fetch_assoc($allUsersDynamicList));
$rows = mysql_num_rows($allUsersDynamicList);
if($rows > 0) {
mysql_data_seek($allUsersDynamicList, 0);
$row_allUsersDynamicList = mysql_fetch_assoc($allUsersDynamicList);
}
?>
</select>
/div></td>
//GROUP 4
<td width="139"><div align="right">
<select name="select7" multiple="multiple" class="calloutForm" id="select7" title="<?php echo $row_allUsers['submittername']; ?>">
<?php
do {
?>
<option value="<?php echo $row_allUsersDynamicList['submittername']?>"><?php echo $row_allUsersDynamicList['submittername']?></option>
<?php
} while ($row_allUsersDynamicList = mysql_fetch_assoc($allUsersDynamicList));
$rows = mysql_num_rows($allUsersDynamicList);
if($rows > 0) {
mysql_data_seek($allUsersDynamicList, 0);
$row_allUsersDynamicList = mysql_fetch_assoc($allUsersDynamicList);
}
?>
</select>
</div></td>
//GROUP 5
<td width="139"><div align="right">
<select name="select9" multiple="multiple" class="calloutForm" id="select9" title="<?php echo $row_allUsers['submittername']; ?>">
<?php
do {
?>
<option value="<?php echo $row_allUsersDynamicList['submittername']?>"><?php echo $row_allUsersDynamicList['submittername']?></option>
<?php
} while ($row_allUsersDynamicList = mysql_fetch_assoc($allUsersDynamicList));
$rows = mysql_num_rows($allUsersDynamicList);
if($rows > 0) {
mysql_data_seek($allUsersDynamicList, 0);
$row_allUsersDynamicList = mysql_fetch_assoc($allUsersDynamicList);
}
?>
</select>
</div></td>
//GROUP 6
<td width="139"><div align="right">
<select name="select11" multiple="multiple" class="calloutForm" id="select11" title="<?php echo $row_allUsers['submittername']; ?>">
<?php
do {
?>
<option value="<?php echo $row_allUsersDynamicList['submittername']?>"><?php echo $row_allUsersDynamicList['submittername']?></option>
<?php
} while ($row_allUsersDynamicList = mysql_fetch_assoc($allUsersDynamicList));
$rows = mysql_num_rows($allUsersDynamicList);
if($rows > 0) {
mysql_data_seek($allUsersDynamicList, 0);
$row_allUsersDynamicList = mysql_fetch_assoc($allUsersDynamicList);
}
?>
</select>
</div></td>