<script language="javascript" type="text/javascript">
function listbox_moveacross(sourceID, destID) {var str = '';
var src = document.getElementById(sourceID);
var dest = document.getElementById(destID);
var j = 0;
for (var count = 0; count < src.options.length; count++) {
if (src.options[count].selected == true) {j++;
}
}
if (j > 2) {alert(
"Maximum 2 Week Of Day you can select")
return false;}
else {
for (var count = 0; count < src.options.length; count++) {
if (src.options[count].selected == true) {
var option = src.options[count];
var newOption = document.createElement("option");newOption.value = option.value;
newOption.text = option.text;
newOption.selected =
true;
if (str.length == 0) {str = option.value;
}
else {str = str +
"," + option.value;}
try {dest.add(newOption,
null); //Standardsrc.remove(count, null);}
catch (error) {dest.add(newOption);
// IE onlysrc.remove(count);
}
count--;
}
}
str = '';
var list = document.getElementById('<%=lstWeekOffDays.ClientID %>');
for (var count = 0; count < list.options.length; count++) {
var option = list.options[count];
var newOption = document.createElement("option");newOption.value = option.value;
newOption.text = option.text;
newOption.selected =
true;
if (str.length == 0) {str = option.value;
}
else {str = str +
"," + option.value;}
}
document.getElementById(
'<%=hdnWeekOffDays.ClientID %>').value = str; }
}
</script>
<table><tr><td><asp:ListBox ID="lstWeekDays" SelectionMode="Multiple" runat="server"></asp:ListBox></td><td><table><tr><td>
<input type="button" class="btnHyperlink" id="HyLeft" value=">>" onclick="listbox_moveacross('<%=lstWeekDays.ClientID %>','<%=lstWeekOffDays.ClientID %>')"; />
</td></tr><tr><td><input type="button" class="btnHyperlink" id="HyRight" value="<<" onclick="listbox_moveacross('<%=lstWeekOffDays.ClientID %>','<%=lstWeekDays.ClientID %>')"; /></td></tr></table></td><td><asp:ListBox ID="lstWeekOffDays" SelectionMode="Multiple" runat="server"></asp:ListBox></td></tr><tr><td><asp:Button runat="server" ID="btnSubmit" Text="Submit" OnClick="btnSubmit_Click" /></td></tr><asp:HiddenField ID="hdnWeekOffDays" runat="server" /></table>
No comments:
Post a Comment