/    Sign up×
Community /Pin to ProfileBookmark

Help with this script please

Ok, I have a list with 12 states on the left, its a switch box so you can swith the names to the right. Now what I am trying to do is when a user makes the selections they want, they stay in the box on the right, can someone help me with this script? Also it will be published on the web, they would be making the changes from a web page, any help or Ideas would be much appreciated. Here is the code I have now.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML><HEAD>
<FORM
action=http://www.my-site??/cgi-bin/script_library/form_handler_file
method=post>
<META http-equiv=Content-Type content=”text/html; charset=windows-1252″>
<SCRIPT language=JavaScript>

<!– Begin
function move(fbox, tbox) {
var arrFbox = new Array();
var arrTbox = new Array();
var arrLookup = new Array();
var i;
for (i = 0; i < tbox.options.length; i++) {
arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength = 0;
var tLength = arrTbox.length;
for(i = 0; i < fbox.options.length; i++) {
arrLookup[fbox.options[i].text] = fbox.options[i].value;
if (fbox.options[i].selected && fbox.options[i].value != “”) {
arrTbox[tLength] = fbox.options[i].text;
tLength++;
}
else {
arrFbox[fLength] = fbox.options[i].text;
fLength++;
}
}
arrFbox.sort();
arrTbox.sort();
fbox.length = 0;
tbox.length = 0;
var c;
for(c = 0; c < arrFbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrFbox[c]];
no.text = arrFbox[c];
fbox[c] = no;
}
for(c = 0; c < arrTbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c];
tbox[c] = no;
}
}
// End –>
</SCRIPT>

<META content=”MSHTML 6.00.2726.2500″ name=GENERATOR></HEAD>
<BODY><FORM name=”combo_box”>
<TABLE>
<TBODY>
<TR>
<TD><SELECT style=”WIDTH: 150px” multiple size=10 name=list1> <OPTION
value=12>Alabama</OPTION> <OPTION value=54>Alaska</OPTION> <OPTION
value=65>Arizona</OPTION> <OPTION value=45 selected>Arkansas</OPTION>
<OPTION value=2>California</OPTION> <OPTION value=6>Colorado</OPTION>
<OPTION value=81>Connecticut</OPTION> <OPTION value=5>Delaware</OPTION>
<OPTION value=23>District of Columbia</OPTION> <OPTION
value=58>Florida</OPTION> <OPTION value=87>Georgia</OPTION> <OPTION
value=98>Hawaii</OPTION></SELECT> </TD>
<TD vAlign=center align=middle><INPUT onclick=move(this.form.list2,this.form.list1) type=button value=”<<“>
<INPUT onclick=move(this.form.list1,this.form.list2) type=button value=”>>”>
</TD>
<TD><SELECT style=”WIDTH: 150px” multiple size=10 name=list2></SELECT>
</TD></TR></TBODY></TABLE></FORM>
<P>
<P><!– Script Size: 4.75 KB –></P></BODY></HTML>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@GollumOct 31.2003 — when a user makes the selections they want, they stay in the box on the right[/QUOTE]

What do you actually mean here?

Are you talking about focus? if so, just add "this.form.list2.focus()" at the end of your onClick handlers for your buttons.


Are you saying "once a selection has moved to the right box, don't let it escape"? In which case you can just remove the button that lets them move them back.
×

Success!

Help @SA_Heat spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...