Click to See Complete Forum and Search --> : Using dropdown list with Checkbox


aturner51
03-05-2003, 12:26 PM
I have written an ASP form that has ten drop down list box, 15 textboxes and two textarea, which is populated using MS SQL stored procedure. When the page is accessed through the browser, the list box has the values already in it.

The user is required to first search the database using a 9-digit number, that retrieves data that may currently be in the database. If the 9-digit number exist and the user has not entered any data, they will be required to fill out the form by selecting the values in the listbox and enter data in the empty text fields. The problem I'm having is with the listbox. I have added a checkbox next to each listbox that allows the user to change the value when necessary. However, if there are more than one listbox that needs to be updated by the user, when they change one listbox by placing a check in the checkbox next to it, and needs to select a second listbox to change by placing a check in another checkbox, it removes the value in the first listbox as if the refresh button once pressed. Here is the syntax below:

<%
If CustodyID = "" or CustodyEdit = 1 Then
Set objDBCmd = Server.CreateObject("ADODB.Command")
With objDBCmd
.ActiveConnection = objDB
.CommandType = adCmdStoredProc
.CommandText = "spCustodyList"
End With

Set objRS = objDBCmd.Execute
Set objDBCmd = Nothing
End If


%>

<font size="2" face="verdana" color="#006563">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Custody:&nbsp;</font><select id="cboCustody" name="CustodyID">
<option></option>
<% If CustodyID = "" or CustodyEdit = 1 Then %>
<%Do While Not objRS.EOF%>
<option value="<%=objRS("CustodyID")%>"><%=objRS("Custody")%>
<%
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
%>
</select><font size="2">
<% Else %>
<option value="<%=CustodyID%>" selected><%=CustodyDesc%>
</select><font size="2" color="#990033">
<input type="checkbox" name="CustodyEdit" value="1" onclick="document.form2.submit()"> <font size="2">Edit</font>

<% End If %>

The same syntax above is used for all listboxes on the form.

Can you tell me how to get around this in my form?

aturner51
03-06-2003, 01:27 PM
I want the user the ability to click a checkbox that will pull the data from the SQL database and populate the listbox, that will allow them to update the existing field currently in the record.

When a user accesses the form they are required to enter a number to verify whether or not the number has been entered. If the number exists, then the record is retrieved and populates the form with the information currently in the database. This allows the user to change any field, i.e., a listbox, textbox, or textarea. If they choose to change a listbox I have placed a checkbox next to each individual listbox, and when the user checks it, it is populated with a list of chooses that a user can pick from.

Examples: Lets say that listbox #1 has a list of all the Penal Codes in the State of California and listbox #2 displays all the statute codes, i.e., Penal, Misdemeanor and Other, and the user wants to change the Penal Code from 242 (Misdemeanor) to 487 (Felony). When the user places a check in the checkbox field, it removes the 242 and now shows all the Penal Codes for the state in the listbox. Once the user changes the selection to 487, the user should be able to place a check in the checkbox next to the Statute Code allowing them to change the code from a Misdemeanor to a Felony. However, what's occurring is that when the second checkbox is selected, it will remove the 487 from listbox #1 as if the page was just refreshed when the second checkbox is clicked. So, for some reason, it's not retaining the information you enter.

1). How can I prevent the first listbox from losing it's data and allow the user to continue to input data into the second listbox and subsequent fields within the form?

Note: The form only allows the user to update the database. They cannot insert or delete records from this form because the number is being entered on a different form.

I want the form to be able to allow the user to make changes to any listbox on a form, retain the information as they click from one field to the other. Do I need to write a javascript or vbscript to accomplish this task?

Help!!!

Ribeyed
03-06-2003, 03:19 PM
hi,
i had a look at your code. There is a lot of code to go through without seeing what the output is. Can you maybe provide a url to this page?

aturner51
03-06-2003, 05:27 PM
Attn: [SWR]Ribeyed

The URL address is assigned to our intranet and cannot be viewed outside our firewall. Is there something else I can provide or make available to you?

Ribeyed
03-06-2003, 06:21 PM
hi,
the database itsself:( or a fair idea of the tables and database structure so i can replicate. If you can send aalmost blank database, anything to replicate whet you have at your end.

aturner51
03-07-2003, 12:01 PM
ATTN: [SWR] Ribeyed and Dave Clark

Here is the script for my SQL table and stored procedures that run my ASP forms. I hope this will help in resolving my problem.