Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > Classic ASP

Reply
 
LinkBack (1) Thread Tools
Old August 29th, 2005, 05:50 PM   1 links from elsewhere to this Post. Click to view. #1
New Member
 

Join Date: Aug 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 codefantom is on a distinguished road
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!??
codefantom is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old August 29th, 2005, 06:28 PM   #2
New Member
 

Join Date: Aug 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 codefantom is on a distinguished road
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.
codefantom is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
repopulate , checkboxes , database


LinkBacks (?)
LinkBack to this Thread: http://webforumz.com/classic-asp/3106-repopulate-checkboxes-from-database.htm
Posted By For Type Date
checkbox This thread Refback January 29th, 2009 11:11 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 4 December 9th, 2007 11:54 PM
FormMail and checkBoxes AGAIN aarrrrgh Morgado Flash and ActionScript 1 August 23rd, 2007 07:56 AM
Help with asp code for checkboxes speakma Classic ASP 1 May 22nd, 2007 07:17 AM
Unchecking specified checkboxes in a table Geovanni Cesar JavaScript 0 March 6th, 2007 04:22 AM
How to get value of selected dynamic checkboxes? frmsasp .NET 1 November 3rd, 2005 08:59 AM


Search Engine Optimization by vBSEO 3.2.0 RC8