firefoxでjavascriptが…
現在、二つのセレクトボックス間でデータのやり取りをするjavascriptを製作しております。ieでは問題なく動作するのですが、firefoxだと
セレクトボックスの移動ボタンを押すと余計なものまで消えてしまいます。どなたかご教授ください。
javascript↓
var master_selected_value;
var master_selected_text;
var user_selected_value;
var user_selected_text;
function select_master(a){
master_selected_text = a.master_list.options[a.master_list.selectedIndex].text;
master_selected_value = a.master_list.options[a.master_list.selectedIndex].value;
}
function select_user(a){
user_selected_text = a.select_list.options[a.select_list.selectedIndex].text;
user_selected_value = a.select_list.options[a.select_list.selectedIndex].value;
}
function portlet_move(a,b,c){
if( 1 == b ){
var sw = 0;
for( n = 0 ; n < a.select_list.length ; n ++ ){
if( a.select_list.options[n].text == master_selected_text){
sw = 1;
}
}
if( sw == 0 && master_selected_text != null ){
a.select_list.options[a.select_list.length] = new Option(master_selected_text,master_selected_value);
}
}else{
if( null != user_selected_text ){
for( n = a.select_list.selectedIndex ; n < a.select_list.length - 1; n ++ ){
a.select_list.options[n] = a.select_list.options[n + 1];
}
a.select_list.length = a.select_list.length - 1;
}
user_selected_text = null;
user_selected_value = null;
}
}
function data_sum(a,b){
var buff = "";
for( n = 0 ; n < a.select_list.length ; n ++ ){
buff = buff + a.select_list.options[n].value;
}
a.select_list_data.value = buff;
a.type.value = b;
a.submit();
}
function data_send(a,b){
var buff = "";
for( n = 0 ; n < a.select_list.length ; n ++ ){
buff = buff + a.select_list.options[n].value;
}
a.select_list_data.value = buff;
a.type.value = b;
a.send.value = "true";
a.submit();
}
html↓
<form method="post" action="test.php" onsubmit="return moveItemSelect('ListBox1','ListBox2');">
<input type="hidden" name="type" value="">
<input type="hidden" name="select_list_data" value="">
<input type="hidden" name="send" value="">
<table>
<tr>
<td>
<select name="type" onchange="data_sum(this.form,'recommended');">
<option value="a" selected="selected">a</option>
<option value="b">b</option>
</select>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td>
<select size="10" name="master_list" onchange="select_master(this.form);">
<option value="1">1</option>
<option value="2">2</option>
</select>
</td>
<td>
<input type="button" class="button" value="→" onclick="portlet_move(this.form,1,2);">
<br />
<input type="button" class="button" value="←" onclick="portlet_move(this.form,2,1);">
</td>
<td>
<select size="10" name="select_list" onchange="select_user(this.form);">
<option value="1">1</option>
</select>
</td>
</tr>
<tr>
<td colspan="3"><input type="button" class="button" value="登録" onclick="data_send(this.form,'recommended_write');" /></td>
</tr>
</table>
</form>
お礼
回答有り難うございました。解決いたしました。