Hello Everyone,
I am new to JavaScript and to this forum so please forgive me for any inaccuracies. My apologies for the long post.
I have a two-part question.
First question:
I have a select multiple loaded with accounts. The user can select various accounts and hits a button and the account will move to my "Selected Accounts" select multiple. This works fine if my input type="button". I want to be able to display an image on the button. When I have <input type=image src...>, the second select multiple shows the account upon selection. But an alert window appears showing account number selected. If I click OK, alert disappears and the second select multiple clears.
Can this be done with an image src on a button? How?
Second question:
I have another button enabling the user to move all contents of first select multiple to second select multiple. When button is clicked, I get windows memory error and IE closes.
Is there a way of doing this? How?
Any and all suggestion would be most appreciated. Below are nippets of my code. If you need more, let me know.
TIA
<Form Name="RptOptions" onSubmit="populateHidden(document.RptOptions.SelAccounts,document.RptOptions.hidden1)">
<select name="AvailAccounts" multiple size="8" style="width:130px;" width="140">
<option value="2300883">2300883
<option value="3889100682">3889100682
<option value="1006970459">1006970459
<option value="1009562127">1009562127
<option value="2222222222">2222222222
<option value="6204803355">6204803355
<option value="9230063411">9230063411
<option value="1111111111">1111111111
<option value="2222222222">2222222222
<option value="3333333333">3333333333
<option value="4444444444">4444444444
</select>
<input type="button" value=" > "image src="button_right.gif" onclick="if (document.images)copySelected(document.RptOptions.AvailAccounts,document.RptOptions.SelAccounts)"><br><br>
<input type=image src="button_all_right.gif" onclick="if (document.images) copyAll (document.RptOptions.AvailAccounts,document.RptOptions.SelAccounts)"><br><br>
<input type="button" value=" < "image src="button_left.gif" onclick="if (document.images) copySelected(document.RptOptions.SelAccounts,document.RptOptions.AvailAccounts)"><br><br>
<input type=image src="button_all_left.gif" onclick="if (document.images) copyAll (document.RptOptions.SelAccounts,document.RptOptions.AvailAccounts)">
<select name="SelAccounts" multiple size="8" style="width:130px;" width="140">
<input type="hidden" name="hidden1">
JavaScript:
function copySelected(fromObject,toObject) {
for (var i=0, l=fromObject.options.length;i<l;i++) {
if (fromObject.options.selected)
addOption(toObject,fromObject.options.text,fromObject.options.value);
}
for (var i=fromObject.options.length-1;i>-1;i--) {
if (fromObject.options.selected)
deleteOption(fromObject,i);
}
}
function copyAll(fromObject,toObject) {
for (var i=0, l=fromObject.options.length;i<l;i++) {
addOption(toObject,fromObject.options.text,fromObject.options.value);
}
for (var i=fromObject.options.length-1;i>-1;i--) {
deleteOption(fromObject,i);
}
}
function populateHidden(fromObject,toObject) {
var output = '';
for (var i=0, l=fromObject.options.length;i<l;i++) {
output += escape(fromObject.name) + '=' + escape(fromObject.options.value) + '&';
}
alert(output);
toObject.value = output;
}
I am new to JavaScript and to this forum so please forgive me for any inaccuracies. My apologies for the long post.
I have a two-part question.
First question:
I have a select multiple loaded with accounts. The user can select various accounts and hits a button and the account will move to my "Selected Accounts" select multiple. This works fine if my input type="button". I want to be able to display an image on the button. When I have <input type=image src...>, the second select multiple shows the account upon selection. But an alert window appears showing account number selected. If I click OK, alert disappears and the second select multiple clears.
Can this be done with an image src on a button? How?
Second question:
I have another button enabling the user to move all contents of first select multiple to second select multiple. When button is clicked, I get windows memory error and IE closes.
Is there a way of doing this? How?
Any and all suggestion would be most appreciated. Below are nippets of my code. If you need more, let me know.
TIA
<Form Name="RptOptions" onSubmit="populateHidden(document.RptOptions.SelAccounts,document.RptOptions.hidden1)">
<select name="AvailAccounts" multiple size="8" style="width:130px;" width="140">
<option value="2300883">2300883
<option value="3889100682">3889100682
<option value="1006970459">1006970459
<option value="1009562127">1009562127
<option value="2222222222">2222222222
<option value="6204803355">6204803355
<option value="9230063411">9230063411
<option value="1111111111">1111111111
<option value="2222222222">2222222222
<option value="3333333333">3333333333
<option value="4444444444">4444444444
</select>
<input type="button" value=" > "image src="button_right.gif" onclick="if (document.images)copySelected(document.RptOptions.AvailAccounts,document.RptOptions.SelAccounts)"><br><br>
<input type=image src="button_all_right.gif" onclick="if (document.images) copyAll (document.RptOptions.AvailAccounts,document.RptOptions.SelAccounts)"><br><br>
<input type="button" value=" < "image src="button_left.gif" onclick="if (document.images) copySelected(document.RptOptions.SelAccounts,document.RptOptions.AvailAccounts)"><br><br>
<input type=image src="button_all_left.gif" onclick="if (document.images) copyAll (document.RptOptions.SelAccounts,document.RptOptions.AvailAccounts)">
<select name="SelAccounts" multiple size="8" style="width:130px;" width="140">
<input type="hidden" name="hidden1">
JavaScript:
function copySelected(fromObject,toObject) {
for (var i=0, l=fromObject.options.length;i<l;i++) {
if (fromObject.options.selected)
addOption(toObject,fromObject.options.text,fromObject.options.value);
}
for (var i=fromObject.options.length-1;i>-1;i--) {
if (fromObject.options.selected)
deleteOption(fromObject,i);
}
}
function copyAll(fromObject,toObject) {
for (var i=0, l=fromObject.options.length;i<l;i++) {
addOption(toObject,fromObject.options.text,fromObject.options.value);
}
for (var i=fromObject.options.length-1;i>-1;i--) {
deleteOption(fromObject,i);
}
}
function populateHidden(fromObject,toObject) {
var output = '';
for (var i=0, l=fromObject.options.length;i<l;i++) {
output += escape(fromObject.name) + '=' + escape(fromObject.options.value) + '&';
}
alert(output);
toObject.value = output;
}