Home > Backend Development > PHP Tutorial > 移动到右边的,为什么要选中后提交才能获取到相应的值。该怎么解决

移动到右边的,为什么要选中后提交才能获取到相应的值。该怎么解决

WBOY
Release: 2016-06-13 12:35:22
Original
849 people have browsed it

移动到右边的,为什么要选中后提交才能获取到相应的值。

本帖最后由 qq914260102 于 2013-10-14 16:02:07 编辑 如果选到右边,是无法获取到值的,必须要点击一次,选中了才能获取到,怎么让右边的默认能获取值








> " onclick="move(this.form.list1,this.form.list2)" name="B1">




sortitems = 1;  // Automatically sort items within lists? (1 or 0)<br />
function move(fbox,tbox) {<br />
for(var i=0; i<fbox.options.length; i++) {<br />
if(fbox.options[i].selected && fbox.options[i].value != "") {<br />
var no = new Option();<br />
no.value = fbox.options[i].value;<br />
no.text = fbox.options[i].text;<br />
tbox.options[tbox.options.length] = no;<br />
fbox.options[i].value = "";<br />
fbox.options[i].text = "";<br />
}<br />
}<br />
BumpUp(fbox);<br />
if (sortitems) SortD(tbox);<br />
}<br />
function BumpUp(box)  {<br />
for(var i=0; i<box.options.length; i++) {<br />
if(box.options[i].value == "")  {<br />
for(var j=i; j<box.options.length-1; j++)  {<br />
box.options[j].value = box.options[j+1].value;<br />
box.options[j].text = box.options[j+1].text;<br />
}<br />
var ln = i;<br />
break;<br />
   }<br />
}<br />
if(ln < box.options.length)  {<br />
box.options.length -= 1;<br />
BumpUp(box);<br />
   }<br />
}<br />
function SortD(box)  {<br />
var temp_opts = new Array();<br />
var temp = new Object();<br />
for(var i=0; i<box.options.length; i++)  {<br />
temp_opts[i] = box.options[i];<br />
}<br />
for(var x=0; x<temp_opts.length-1; x++)  {<br />
for(var y=(x+1); y<temp_opts.length; y++)  {<br />
if(temp_opts[x].text > temp_opts[y].text)  {<br />
temp = temp_opts[x].text;<br />
temp_opts[x].text = temp_opts[y].text;<br />
temp_opts[y].text = temp;<br />
temp = temp_opts[x].value;<br />
temp_opts[x].value = temp_opts[y].value;<br />
temp_opts[y].value = temp;<br />
      }<br />
   }<br />
}<br />
for(var i=0; i<box.options.length; i++)  {<br />
box.options[i].value = temp_opts[i].value;<br />
box.options[i].text = temp_opts[i].text;<br />
   }<br />
}
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template