Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submitting select list choices to an action form

Status
Not open for further replies.

buckinator

Technical User
Apr 10, 2002
3
US
I have a code that has two select boxes. You choose your options that are listed in the first select box and then submit them to the second select box as your choices. When I hit the submit button, the choices do not pass over to the action page. A copy of the code is pasted below. Could someone review the code and see if they could tell me why the selected items are not passing over to the action form. Thanks.

<cfquery name=&quot;CustomerList_2001R1&quot; datasource=&quot;Survey&quot; dbtype=&quot;ODBC&quot;>
SELECT Customer, BEMSID
FROM All_Depts
ORDER BY Customer, BEMSID</cfquery>

<!---
<table align=&quot;center&quot;>
<tr bgcolor=&quot;#0000FF&quot;>
<td><strong>Customer</strong></td>
<td><strong>BEMSID</strong></td>
</tr>
<cfoutput query=&quot;CustomerList_2001R1&quot;>
<tr>
<td>#Customer#</td>
<td>#BEMSID#</td>
</tr>
</cfoutput>
</table>
--->

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<html>
<head>
<title>ENGINEERING CUSTOMER LIST</title>

<script type=&quot;text/javascript&quot;>

function OnTransferBtnClick(blnFromLeft)
{
var LeftListBox = document.forms[0].lstLeft;
var RightListBox = document.forms[0].lstRight;
var ListItems = new Array();
FromList = (blnFromLeft ? LeftListBox : RightListBox);
ToList = (blnFromLeft ? RightListBox : LeftListBox);
for(var i=(FromList.options.length - 1);i>=0;i--)
if(FromList.options.selected)
{
ListItems[ListItems.length] = new Option(FromList.options.text);
FromList.options = null;
}
<!----Added the following for loop to replace this for loop

for(var i=ListItems.length - 1;i>=0;i--)
ToList.options[ToList.options.length] = ListItems;
--->
for(var i=ListItems.length - 1;i>=0;i--) {
ToList.options[ToList.options.length - 1] = ListItems;
ToList.options.length++;
}
}

function OnBtnSubmitClick(f)
{
ListBox = document.forms[0].lstRight;
alert(&quot;lstbox&quot; + f.lstRight.options[0].text);

if(ListBox.options.length==0){
alert(&quot;You did not selection any item/items. Please choose an item/items from the left list box and transfer them to the right list box&quot;);
}
else
{
f.submit();
}

}


</script>
</head>

<body bgColor=&quot;#FFFFF0&quot;>

<form action=&quot;insert3.cfm&quot; method=&quot;post&quot; name=&quot;f&quot; id=&quot;f&quot;>
<input type=&quot;hidden&quot; name=&quot;test&quot; value=&quot;testing&quot;>

Please Choose Your Engineering Boeing Customer(s)
<table>

<tr>
<td>
<select name=&quot;lstLeft&quot; MULTIPLE size=&quot;15&quot;>
<cfoutput query=&quot;CustomerList_2001R1&quot;>
<Option value=&quot;#BEMSID#&quot;>#Customer#</cfoutput>

</select>
</td>
<td>

</td>
<td>
<table>
<tr>
<td>
<input Type=&quot;Button&quot; Name=&quot;btnLtoR&quot; Value=&quot; >> &quot;
onclick=&quot;OnTransferBtnClick(true)&quot; title=&quot;Transfer Items Selected in the
Left List Box to the Right List Box&quot;>
</td>
</tr>
<tr>
<td>
<input Type=&quot;Button&quot; Name=&quot;btnRtoL&quot; Value=&quot; << &quot;
onclick=&quot;OnTransferBtnClick(false)&quot; title=&quot;Transfer Items Selected in the
Right List Box to the Left List Box&quot;>
</td>
</tr>
</table>
</td>
<td>

</td>
<td>
<select name=&quot;lstRight&quot; MULTIPLE size=&quot;15&quot;>
<Option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

</select>
</td>
</tr>
<tr>
<td>
<input type=&quot;button&quot; name=&quot;btnSubmit&quot; value=&quot;OK&quot; onClick=&quot;OnBtnSubmitClick(this.form);&quot;>
</td>
</tr>
</table>
</form>
</body>
</html>

(Action Page Code)
<html>
<head>
<title>Untitled</title>
</head>

<body>
<cfoutput>
The customer list is:#form.lstRight#
</cfoutput>
<cfoutput>
<p>Customers selected are:#REMOTE_ADDR#
<P>Test=#testing#

</cfoutput>

</body>
</html>





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top