1
是否有可能在將項目從一個選擇列表移動到其他選擇列表時以某種方式複製選項屬性。這是我的JavaScript
這增加了項目的其他列表:PHP/JavaScript添加新選項
function addUser(form) {
var fl = form.resources.length -1;
var au = form.assigned.length -1;
//gets value of percentage assignment of selected resource
var perc = form.percentage_assignment.options[form.percentage_assignment.selectedIndex].value;
var users = "x";
//build array of assiged users
for (au; au > -1; au--) {
users = users + "," + form.assigned.options[au].value + ","
}
//Pull selected resources and add them to list
for (fl; fl > -1; fl--) {
if (form.resources.options[fl].selected && users.indexOf("," + form.resources.options[fl].value + ",") == -1) {
t = form.assigned.length
opt = new Option(form.resources.options[fl].text+" ["+perc+"%]", form.resources.options[fl].value);
form.hperc_assign.value += form.resources.options[fl].value+"="+perc+";";
form.assigned.options[t] = opt
}
}
}
問題是,當它增加了該項目的其他selectlist
它沒有屬性。 這裏是一個例子:
列表1
<option style="color:''" value="''">Option1</option>
而當我把這個項目從列表1至表2:
<option>Option1</option>
所以我重複的問題,是有可能以某種方式複製或移動物品的屬性?
第二個問題是maby有人知道我在做什麼錯在這裏因爲我得到的錯誤,我該怎麼刪除或添加修復它?
$titleBlock->addCell('<select class="text" size="1" name="user_id">
<?php
$sql = "SELECT user_id, user_color FROM dotp_users";
$result = mysql_query($sql) or die(mysql_error());
$new = array();
while($row = mysql_fetch_assoc($result)) {
$new[$row['user_id']] = $row['user_color'];
}
foreach ($user_list as $key=>$value){
echo '<option style="color:'.$new[$key].'" value="'.$key.'">'.$value.'</option>';
}
?>
</select>', '',
'<form action="?m=tasks" method="post" name="userIdForm">','</form>');
好吧我會改變它,但它沒有任何影響。 – Sidas