repopulate checkboxes from database

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 29th, 2005, 21:50
New Member
Join Date: Aug 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
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!??
Reply With Quote

  #2 (permalink)  
Old Aug 29th, 2005, 22:28
New Member
Join Date: Aug 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
Reply

Tags
repopulate, checkboxes, database

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 06:23.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43