Forum Moderators: open
<%@ Page Title="Associated Staffing: Find a Job" Language="VB" MasterPageFile="~/InternalMaster.master" AutoEventWireup="false"
CodeFile="FindAJob.aspx.vb" Inherits="JobSeekers_FindAJob" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<script src="../Error.js" type="text/javascript"></script>
<script type = "text/javascript" language = "javascript">
function fnMoveItems(bxFrom, bxTo) {
var varFromBox = document.getElementById(bxFrom);
var varToBox = document.getElementById(bxTo);
if ((varFromBox != null) && (varToBox != null)) {
if (varFromBox.length < 1) {
alert('There are no items in the source ListBox');
return false;
}//if
if (varFromBox.options.selectedIndex == -1) // when no Item is selected the index will be -1
{
alert('Please select an Item to move');
return false;
}//if
while (varFromBox.options.selectedIndex >= 0) {
var optn = document.createElement("OPTION");
optn.text = varFromBox.options[varFromBox.options.selectedIndex].text;
optn.value = varFromBox.options[varFromBox.options.selectedIndex].value;
varToBox.options.add(optn);
varFromBox.remove(varFromBox.options.selectedIndex); //Remove the item from Source Listbox
}//while
}//if
return false;
}//fnMoveItems
function moveSelections(bxFrom, bxTo) {
var varFromBox = document.getElementById(bxFrom);
var varToBox = document.getElementById(bxTo);
if (varFromBox.options.length < 1) {
alert('There are no items in that box');
return false;
} //if
for (var i = 0; i < varFromBox.options.length; ++i) {
var newOption = new Option(); // Create a new instance of ListItem
newOption.text = varFromBox.options[i].text;
newOption.value = varFromBox.options[i].value;
varToBox.options[varToBox.options.length] = newOption; //Append the item in Target Listbox
} //for
var i = 0;
var len = varFromBox.options.length;
while (varFromBox.options.length > 1) {
if (varFromBox.options.length = 1) {
varFromBox.remove(0); //Remove the item from Source Listbox
} //if length = 1
else {
varFromBox.remove(1);
} //else
}//while
}//moveSelections
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Title" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<table style="width: 700px">
<tr>
<td style="width: 104px" align="center">
Select the categories you are interested in:
</td>
<td style="width: 133px">
<!-- Filler -->
</td>
<td style="width: 110px">
Current Selections:
</td>
</tr>
<tr>
<td align="center">
<asp:ListBox ID="choices" Width="200px" Height = "200px" runat="server"
SelectionMode="Multiple" DataSourceID="Categories" DataTextField="Category"
DataValueField="CategoryID">
</asp:ListBox>
<asp:SqlDataSource ID="Categories" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConn %>"
SelectCommand="SELECT [Category], [CategoryID] FROM [Categories] ORDER BY [Category]">
</asp:SqlDataSource>
</td>
<td style="width: 133px">
<table>
<tr><td>
<input id="moveSingle" type="button" value=">" onclick = "return fnMoveItems('<%= choices.ClientID %>','<%= selections.ClientID %>');" />
</td></tr>
<tr><td>
<input id="moveAll" type="button" value=">>>" onclick = "return moveSelections('<%= choices.ClientID %>','<%= selections.ClientID %>');" />
</td></tr>
<tr><td>
<input id="removeOne" type="button" value="<" onclick = "return fnMoveItems('<%= selections.ClientID %>','<%= choices.ClientID %>');"/>
</td></tr>
<tr><td>
<input id="removeAll" type="button" value="<<<" onclick = "return moveSelections('<%= selections.ClientID %>','<%= choices.ClientID %>');" />
</td></tr>
</table>
</td>
<td style="width: 110px">
<asp:ListBox ID="selections" Width="200px" Height = "200px" runat="server" SelectionMode="Multiple">
</asp:ListBox>
</td>
</tr>
</table><br />
Branch or Division<br />
<asp:DropDownList ID="branchDrop" runat="server" DataSourceID="Branches"
DataTextField="Branch" DataValueField="BranchID"
AppendDataBoundItems = "true">
<asp:ListItem Value="ALL" Text = "--- All Branches ---"></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="Branches" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConn %>"
SelectCommand="SELECT [Branch], [BranchID] FROM [Branches]">
</asp:SqlDataSource>
<br />
Enter Search Keywords<br />
<asp:TextBox ID="searchInput" runat="server"></asp:TextBox><br />
Jobs that match ANY of my keywords: <asp:RadioButton ID="anyKeyWords" runat="server" GroupName = "searchCriteria" />
<asp:Label ID="errorRadio" CssClass = "errorAstrix" runat="server"></asp:Label><br />
-- OR --<br />
Jobs that match ALL of my keywords: <asp:RadioButton ID="allKeyWords" runat="server" GroupName = "searchCriteria" /><br />
<asp:Button ID = "search" Text = "Search" runat = "server" />
</asp:Content>
var varFromBox = document.getElementById(bxFrom);
var varToBox = document.getElementById(bxTo);
if ((varFromBox != null) && (varToBox != null)) {
if (varFromBox.length < 1) {
alert('There are no items in the source ListBox');
return false;
} //if
if (varFromBox.options.selectedIndex == -1) // when no Item is selected the index will be -1
{
alert('Please select an Item to move');
return false;
} //if
while (varFromBox.options.selectedIndex >= 0) {
var optn = document.createElement("OPTION");
optn.text = varFromBox.options[varFromBox.options.selectedIndex].text;
optn.value = varFromBox.options[varFromBox.options.selectedIndex].value;
varToBox.options.add(optn);
varFromBox.remove(varFromBox.options.selectedIndex); //Remove the item from Source Listbox
} //while
var temp = "";
//now add the items to the hidden field
for (var i = 0; i < varToBox.options.length; ++i) {
//add all of the values in the to box
//to a variable separating each selection id
//with a ,
temp += varToBox.options[i].value + ",";
} //for
//remove the last character of temp
//because it is an extra ,
var values = temp.substring(0, temp.length - 1);
var h = document.getElementById(hiddenId);
h.value = values;
} //if
return false;
} //fnAddItems
//this function removes one item from the
//second listbox and removes it from
//the hidden field
function fnRemoveItems(bxFrom, bxTo, hiddenId) {
var varFromBox = document.getElementById(bxFrom);
var varToBox = document.getElementById(bxTo);
if ((varFromBox != null) && (varToBox != null)) {
if (varFromBox.length < 1) {
alert('There are no items in the source ListBox');
return false;
} //if
if (varFromBox.options.selectedIndex == -1) // when no Item is selected the index will be -1
{
alert('Please select an Item to move');
return false;
} //if
while (varFromBox.options.selectedIndex >= 0) {
var optn = document.createElement("OPTION");
optn.text = varFromBox.options[varFromBox.options.selectedIndex].text;
optn.value = varFromBox.options[varFromBox.options.selectedIndex].value;
varToBox.options.add(optn);
varFromBox.remove(varFromBox.options.selectedIndex); //Remove the item from Source Listbox
} //while
} //if
var temp = "";
//now remove the items to the hidden field
for (var i = 0; i < varFromBox.options.length; ++i) {
//add all of the values in the to box
//to a variable separating each selection id
//with a ,
temp += varFromBox.options[i].value + ",";
} //for
//remove the last character of temp
//because it is an extra ,
var values = temp.substring(0, temp.length - 1);
var h = document.getElementById(hiddenId);
h.value = values;
return false;
} //fnRemoveItems
//this function moves all of the slections over and adds
//them to the hidden field
function moveSelections(bxFrom, bxTo, hiddenId) {
var varFromBox = document.getElementById(bxFrom);
var varToBox = document.getElementById(bxTo);
if (varFromBox.options.length < 1) {
alert('There are no items in that box');
return false;
} //if
for (var i = 0; i < varFromBox.options.length; ++i) {
var newOption = new Option(); // Create a new instance of ListItem
newOption.text = varFromBox.options[i].text;
newOption.value = varFromBox.options[i].value;
varToBox.options[varToBox.options.length] = newOption; //Append the item in Target Listbox
} //for
var i = 0;
var len = varFromBox.options.length;
while (varFromBox.options.length > 1) {
if (varFromBox.options.length = 1) {
varFromBox.remove(0); //Remove the item from Source Listbox
} //if length = 1
else {
varFromBox.remove(1);
} //else
} //while
//add the value all to the listbox
document.getElementById(hiddenId).value = "ALL";
} //moveSelections
//this function removes all of the items
//from the second list box and removes them
//from the hidden field.
function removeSelections(bxFrom, bxTo, hiddenId) {
var varFromBox = document.getElementById(bxFrom);
var varToBox = document.getElementById(bxTo);
if (varFromBox.options.length < 1) {
alert('There are no items in that box');
return false;
} //if
for (var i = 0; i < varFromBox.options.length; ++i) {
var newOption = new Option(); // Create a new instance of ListItem
newOption.text = varFromBox.options[i].text;
newOption.value = varFromBox.options[i].value;
varToBox.options[varToBox.options.length] = newOption; //Append the item in Target Listbox
} //for
var i = 0;
var len = varFromBox.options.length;
while (varFromBox.options.length >= 1) {
if (varFromBox.options.length = 1) {
varFromBox.remove(0); //Remove the item from Source Listbox
} //if length = 1
else {
varFromBox.remove(1);
} //else
} //while
//add the value all to the listbox
document.getElementById(hiddenId).value = "";
} //removeSelections
You have to keep a hidden value to get the information back on the server side.
In the end, if your other solution works then use it... just pointing out there are more efficient ways to solve that problem.