This is a discussion on "repopulate checkboxes from database" within the Classic ASP section. This forum, and the thread "repopulate checkboxes from database are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
repopulate checkboxes from database
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
repopulate checkboxes from database
I need this code modified. I know it works because I took it from a generated page from ASPMAKER. But I'm trying to implement it with the code from my page.
[code] <% Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "Data Source=" & Server.Mappath("db.mdb") & ";Provider=Microsoft.Jet.OLEDB.4.0;" sSqlWrk = "SELECT [U_DISPUTES] FROM [DISPUTES] ORDER BY [U_DISPUTES] Asc" Set rswrk = Server.CreateObject("ADODB.Recordset") rswrk.Open sSqlWrk, conn, 1, 2 If Not rswrk.Eof Then datawrk = rswrk.GetRows rowswrk = UBound(datawrk, 2) 'Dim ar_x_DISPUTES, ari_x_DISPUTES ar_x_DISPUTES = split(DAT_DISPUTE&"",",") For rowcntwrk = 0 To rowswrk x_DISPUTESChk = x_DISPUTESChk & "<input type='checkbox' name='DAT_DISPUTE' value='" & datawrk(0, rowcntwrk) & "'" For ari_x_DISPUTES = 0 to UBound(ar_x_DISPUTES) If CStr(datawrk(0, rowcntwrk)&"") = Trim(ar_x_DISPUTES(ari_x_DISPUTES)&"") Then x_DISPUTESChk = x_DISPUTESChk & " checked" Exit For End If Next x_DISPUTESChk = x_DISPUTESChk & ">" & datawrk(0, rowcntwrk) & EditOptionSeparator(rowcntwrk) Next End If rswrk.Close Set rswrk = Nothing Response.Write x_DISPUTESChk %> [code] But know I get this error message: [code] Microsoft VBScript runtime (0x800A000D) Type mismatch: 'EditOptionSeparator' /myweb/ducredit/includes/inc_edit.asp, line 434 [code] This won't display unless I take out the " & EditOptionSeparator(rowcntwrk)" portion When I do take it out it goes back to my original problem displayed checkboxes on my edit page without repopulating the previous choses. Does anyone know what this "EditOptionSeparator" is and can it be change to something else so that it works. Can the code be simplified so you no longer need the "EditOptionSeparator" portion? Can anyone help!?? |
|
|
|
|||
|
I found the function that this is attached to "EditOptionSeparator" but there has to be a simplier way to write this code.
I will show both parts this time The form element: [code] <% Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "Data Source=" & Server.Mappath("db.mdb") & ";Provider=Microsoft.Jet.OLEDB.4.0;" sSqlWrk = "SELECT [U_DISPUTES] FROM [DISPUTES] ORDER BY [U_DISPUTES] Asc" Set rswrk = Server.CreateObject("ADODB.Recordset") rswrk.Open sSqlWrk, conn, 1, 2 If Not rswrk.Eof Then datawrk = rswrk.GetRows rowswrk = UBound(datawrk, 2) 'Dim ar_x_DISPUTES, ari_x_DISPUTES ar_x_DISPUTES = split(DAT_DISPUTE&"",",") For rowcntwrk = 0 To rowswrk x_DISPUTESChk = x_DISPUTESChk & "<input type='checkbox' name='DAT_DISPUTE' value='" & datawrk(0, rowcntwrk) & "'" For ari_x_DISPUTES = 0 to UBound(ar_x_DISPUTES) If CStr(datawrk(0, rowcntwrk)&"") = Trim(ar_x_DISPUTES(ari_x_DISPUTES)&"") Then x_DISPUTESChk = x_DISPUTESChk & " checked" Exit For End If Next x_DISPUTESChk = x_DISPUTESChk & ">" & datawrk(0, rowcntwrk) & EditOptionSeparator(rowcntwrk) x_DISPUTESChk = x_DISPUTESChk & " " Next End If rswrk.Close Set rswrk = Nothing Response.Write x_DISPUTESChk %> [code] And the function: [code] ' Function to generate Edit Option Separator based on current row count (Radio / CheckBox) ' rowcnt - zero based row count ' Function EditOptionSeparator(rowcnt) EditOptionSeparator = "" ' Sample code to adjust 2 options per row 'If ((rowcnt + 1) Mod 2 = 0) Then ' 2 options per row 'EditOptionSeparator = EditOptionSeparator & " " 'End If End Function %> [code] Any help is appreciated. |
![]() |
| Tags |
| repopulate, checkboxes, database |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Form to email script with checkboxes | Posie | PHP Forum | 4 | Dec 10th, 2007 03:54 |
| FormMail and checkBoxes AGAIN aarrrrgh | Morgado | Flash & Multimedia Forum | 1 | Aug 23rd, 2007 11:56 |
| Help with asp code for checkboxes | speakma | Classic ASP | 1 | May 22nd, 2007 11:17 |
| Unchecking specified checkboxes in a table | Geovanni Cesar | JavaScript Forum | 0 | Mar 6th, 2007 08:22 |
| How to get value of selected dynamic checkboxes? | frmsasp | ASP.NET Forum | 1 | Nov 3rd, 2005 12:59 |