VentureNewBie
Programmer
Hi!
This is the piece of code.
I would like to know how I can remove all the items from ListBox1 and populate the same items in ListBox2 when the user clicks on a button named "SelectAll"
<%@ Language=VBScript %>
<HTML>
<HEAD>
<LINK REL="stylesheet" TYPE="text/css" HREF="../tms.css">
<title>Trial Menu Page</title>
</HEAD>
<form name=TrialMenuPage method=post>
<BODY>
<%
Set oConn = Server.CreateObject("ADODB.Connection"
'This line creates an ADO Connection Object named oConn.
'To use the oConn ADO connection we must first open it:
oConn.Open("provider=SQLOLEDB.1;UserId=tmsuser;password=tms;Initial Catalog=TMS;data source=testing-tms;"
set oRs = Server.CreateObject("ADODB.Recordset"
oRs.ActiveConnection = oConn
oRs.CursorType = 1
oRs.LockType = 1
oRs.Open "SELECT BankID, BankShortName from BankMaster order by BankShortName"
%>
<SCRIPT LANGUAGE=javascript>
<!--
/* Add groups selected from lstSelected list box to lstAvailable list box */
function Select_All()
{
/* Find selected items to add */
var cSelect = document.all.item("lstSelected" /* Listbox1 */
var cOut = document.all.item("lstAvailable" /* Listbox2 */
for (var i=0; i < cSelect.options.length; i++)
{
/* Check to see if a particular option is selected */
if(cSelect.options(i).selected)
{
/* Add new option to "Groups Selected" list box */
cOut.options[cOut.options.length]= new Option(cSelect.options(i).text, "value " + i);
cSelect.remove(i)
}
}
}
-->
</SCRIPT>
<center><h3>Trial Menu Page</h3></center>
<TABLE align="center" border=0 cellPadding=1 cellSpacing=1 style="HEIGHT: 208px; WIDTH: 444px"
width="75%">
<TR>
<TD><SELECT multiple id=lstAvailable name=lstAvailable size=2 style="HEIGHT: 204px; WIDTH: 186px">
</SELECT></TD>
<TD>
<P><INPUT id=btnSelectAll name=btnSelectAll type=button value=">>" style="HEIGHT: 24px; WIDTH: 57px" onclick="Select_All()"></P>
<P><INPUT id=btnSelectOne name=btnSelectOne type=button value=">" style="HEIGHT: 24px; WIDTH: 57px" onclick="Select_One()"></P>
<P><INPUT id=btnDeSelectAll name=btnDeSelectAll type=button value="<" style="HEIGHT: 24px; WIDTH: 55px" onclick="Deselect_One()"></P>
<P><INPUT id=btnDeSelectOne name=btnDeSelectOne type=button value="<<" style="HEIGHT: 24px; WIDTH: 57px" onclick="Deselect_All()"><br></P>
<CENTER> </CENTER>
</TD>
<TD><SELECT id="lstSelected" name="lstSelected" size=10 style="HEIGHT: 204px; WIDTH: 186px" onclick="Select_All()">
<%while Not oRs.EOF%>
<OPTION value="<%=oRs.Fields(0).Value%>" selected> <%=oRs.Fields(1).Value%></OPTION>
<%oRs.MoveNext()
wend
%>
</SELECT>
</TD>
</TR>
</TABLE>
<INPUT id=btnNext name=btnNext type=button value=Next style="HEIGHT: 24px; WIDTH: 54px">
<INPUT id=btnFinish name=btnFinish type=button value=Finish>
</P>
<input type="hidden" name="SelectFlag">
</BODY>
</form>
</HTML>
This is the piece of code.
I would like to know how I can remove all the items from ListBox1 and populate the same items in ListBox2 when the user clicks on a button named "SelectAll"
<%@ Language=VBScript %>
<HTML>
<HEAD>
<LINK REL="stylesheet" TYPE="text/css" HREF="../tms.css">
<title>Trial Menu Page</title>
</HEAD>
<form name=TrialMenuPage method=post>
<BODY>
<%
Set oConn = Server.CreateObject("ADODB.Connection"
'This line creates an ADO Connection Object named oConn.
'To use the oConn ADO connection we must first open it:
oConn.Open("provider=SQLOLEDB.1;UserId=tmsuser;password=tms;Initial Catalog=TMS;data source=testing-tms;"
set oRs = Server.CreateObject("ADODB.Recordset"
oRs.ActiveConnection = oConn
oRs.CursorType = 1
oRs.LockType = 1
oRs.Open "SELECT BankID, BankShortName from BankMaster order by BankShortName"
%>
<SCRIPT LANGUAGE=javascript>
<!--
/* Add groups selected from lstSelected list box to lstAvailable list box */
function Select_All()
{
/* Find selected items to add */
var cSelect = document.all.item("lstSelected" /* Listbox1 */
var cOut = document.all.item("lstAvailable" /* Listbox2 */
for (var i=0; i < cSelect.options.length; i++)
{
/* Check to see if a particular option is selected */
if(cSelect.options(i).selected)
{
/* Add new option to "Groups Selected" list box */
cOut.options[cOut.options.length]= new Option(cSelect.options(i).text, "value " + i);
cSelect.remove(i)
}
}
}
-->
</SCRIPT>
<center><h3>Trial Menu Page</h3></center>
<TABLE align="center" border=0 cellPadding=1 cellSpacing=1 style="HEIGHT: 208px; WIDTH: 444px"
width="75%">
<TR>
<TD><SELECT multiple id=lstAvailable name=lstAvailable size=2 style="HEIGHT: 204px; WIDTH: 186px">
</SELECT></TD>
<TD>
<P><INPUT id=btnSelectAll name=btnSelectAll type=button value=">>" style="HEIGHT: 24px; WIDTH: 57px" onclick="Select_All()"></P>
<P><INPUT id=btnSelectOne name=btnSelectOne type=button value=">" style="HEIGHT: 24px; WIDTH: 57px" onclick="Select_One()"></P>
<P><INPUT id=btnDeSelectAll name=btnDeSelectAll type=button value="<" style="HEIGHT: 24px; WIDTH: 55px" onclick="Deselect_One()"></P>
<P><INPUT id=btnDeSelectOne name=btnDeSelectOne type=button value="<<" style="HEIGHT: 24px; WIDTH: 57px" onclick="Deselect_All()"><br></P>
<CENTER> </CENTER>
</TD>
<TD><SELECT id="lstSelected" name="lstSelected" size=10 style="HEIGHT: 204px; WIDTH: 186px" onclick="Select_All()">
<%while Not oRs.EOF%>
<OPTION value="<%=oRs.Fields(0).Value%>" selected> <%=oRs.Fields(1).Value%></OPTION>
<%oRs.MoveNext()
wend
%>
</SELECT>
</TD>
</TR>
</TABLE>
<INPUT id=btnNext name=btnNext type=button value=Next style="HEIGHT: 24px; WIDTH: 54px">
<INPUT id=btnFinish name=btnFinish type=button value=Finish>
</P>
<input type="hidden" name="SelectFlag">
</BODY>
</form>
</HTML>