Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2003
    Location
    San Bernardino, California
    Posts
    2

    Cool Unanswered: Using a Checkbox to Edit a Drop Down box

    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"> Custody: </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 %>


    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!!!

  2. #2
    Join Date
    Mar 2003
    Location
    San Bernardino, California
    Posts
    2

    Re: Using a Checkbox to Edit a Drop Down box

    Originally posted by Alice Turner
    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"> Custody: </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 %>


    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!!!
    Attached Files Attached Files
    Last edited by Alice Turner; 03-12-03 at 13:48.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •