remedy_rider
asked on
aspupload using multiple checkboxes with the same name
Hello, I found part of the solution and i have all the field info response.writing but i don't know how to get the values to combine as a comma delimited string to enter into the database. Below is the test i set up. and here is what the page looks like:
title= 44444444
action= insert
sec= Symptoms
section= Symptoms
content_type= ABOUT
FCKeditor1=
Enter content body copy here
user_types= SELFCARE
user_types= CAREGIVER
user_types= PROVIDER
age_group= CHILD
age_group= TEEN
age_group= ADULT
age_group= SENIOR
co_morbid= Obesity
co_morbid= Cardiovascular Disease/Heart Disease
co_morbid= Hypertension/High Blood Pressure
co_morbid= Foot Disease
description=
Submit= Insert this record
i need to get user_types, age_group and co_morbid to enter into the database as a comma delimited string.
title= 44444444
action= insert
sec= Symptoms
section= Symptoms
content_type= ABOUT
FCKeditor1=
Enter content body copy here
user_types= SELFCARE
user_types= CAREGIVER
user_types= PROVIDER
age_group= CHILD
age_group= TEEN
age_group= ADULT
age_group= SENIOR
co_morbid= Obesity
co_morbid= Cardiovascular Disease/Heart Disease
co_morbid= Hypertension/High Blood Pressure
co_morbid= Foot Disease
description=
Submit= Insert this record
i need to get user_types, age_group and co_morbid to enter into the database as a comma delimited string.
<!--#include file="variables_set.asp"-->
<!--#include file="connection.asp"-->
<%
Set Upload = Server.CreateObject("Persits.Upload")
Dim cont_id,sec
' we use memory uploads, so we must limit file size - THIS IS SET TO 50mb
Upload.SetMaxSize 26214400, True
' Save to memory. Path parameter is omitted
Count = Upload.Save
' Obtain file object
Set File = Upload.Files("THEFILE")
' Build ADO connection string
'Connect = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath(".\aspupload.mdb")
cont_id=Upload.form("id")
sec=Upload.form("sec")
' If you use SQL Server, the connecton string must look something like this:
Connect = "Provider=SQLOLEDB;Server=67.59.176.188;Database="&dbasename&";UID=velocity;PWD=********y"
' Use ADO Recordset object
Set rs = Server.CreateObject("adodb.recordset")
' Optional: check whether this file already exists using MD5 hash
'Hash = File.MD5Hash
'rs.Open "SELECT * from DOCS WHERE Hash='" & Hash & "'", Connect, 2, 3
'If Not rs.EOF Then
'prod_id=Upload.Form("prod_id")
'Response.redirect"doc_new.asp?stat=filefound&prodid="&prod_id&"&prod="&prodname&""
'End If
'rs.Close
' Reopen recordset to insert file
rs.Open "CONTENT", Connect, 3, 3
rs.AddNew
rs("title") = Upload.Form("title")
rs("content_type") = Upload.Form("content_type")
rs("section") = Upload.Form("section")
For Each Item in Upload.Form
Response.Write Item.Name & "= " & Item.Value & "<BR>"
Next
Set Upload = Nothing
%>
ASKER
LOL... me... government. that's funny. Nope, just working on a diabetes site. I was able to get the values in using your code. I needed them to go into their own fields which i figured out, but i'm stuck on stripping out the trailing comma. :( any ideas? I attached the code snipplet i have working.
for example, this is what the user_types field looks like when i selected all check boxes.
SELFCARE,CAREGIVER,PROVIDE R,
just need to get rid of the comma at the end.
I really appreciate the help!
for example, this is what the user_types field looks like when i selected all check boxes.
SELFCARE,CAREGIVER,PROVIDE
just need to get rid of the comma at the end.
I really appreciate the help!
rs.Open "CONTENT", Connect, 3, 3
rs.AddNew
For Each Item in Upload.Form
if Item.Name="user_types" then
RS("user_types")=RS("user_types") & Item.Value & ","
end if
if Item.Name="age_group" then
RS("age_group")=RS("age_group") & Item.Value & ","
end if
if Item.Name="co_morbid" then
RS("co_morbid")=RS("co_morbid") & Item.Value & ","
end if
if Item.Name="related_sections" then
RS("related_sections") =RS("related_sections") & Item.Value & ","
end if
Next
rs("title") = Upload.Form("title")
rs("content_type") = Upload.Form("content_type")
rs("section") = Upload.Form("section")
rs("sub_section") = Upload.Form("sub_section")
rs("body_content") = Upload.Form("FCKeditor1")
rs("created") = date()
rs("modified") = date() & " " & time()
rs.Update
rs.movelast
new_id = rs("id")
section= rs("section")
con_type=rs("content_type")
set rs = Nothing
ah HA! you missed the final line in my solution ;) here it is, inside your code:
if Item.Name="related_sections" then
RS("related_sections") =RS("related_sections") & Item.Value & ","
end if
Next
RS("related_sections")=left(RS("related_sections"),RS("related_sections").length-1)
perform the same for each other DB field that you created in this way... ;)
ASKER
bummer: Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'rs(...).length'
/d_CARE/cms/content-insert .asp, line 56
Object doesn't support this property or method: 'rs(...).length'
/d_CARE/cms/content-insert
ASKER
I got it. :) RS("related_sections")=Lef t(RS("rela ted_sectio ns"), Len(RS("related_sections") ) - 1)
You really helped me through that one, thanks again Max!
You really helped me through that one, thanks again Max!
oh, crap... just a sec i'll look up the proper way to find out the length of a string...
ok here it is... i was in .Net... my bad...
ok here it is... i was in .Net... my bad...
RS("related_sections")=left(RS("related_sections"),len(RS("related_sections"))-1)
perform the same for each other DB field that you created in this way...
yes there you go! hehe! sorry again... my mind was in .Net mindset =)
ASKER
I forgot to ask about the update script. i'm close but no cigar. here's what the sql is writing:
Update CONTENT Set title='TESTING NEWS NEW INSERT SCRIPT', user_types='SELFCARE, CAREGIVER, PROVIDERPROVIDER', age_group='CHILD,TEEN, ADULT, SENIORSENIOR', co_morbid='Foot Disease', related_sections='Behavior & Lifestyle Management, Complications, Prevention & Risk Reduction, Testing & MonitoringTypes of Diabetes', content_type='NEWS', section='', sub_section='', body_content='
Enter content body copy hereASDFASDFASDF
', modified='5/12/2009 3:46:33 PM' where id=335
you can see it's getting rid of the last comma, then adding the last value? and i added multiple items in co_morbid and it's only bringing 1 over. It's probably something so easy, just having a rough day and can't seem to move forward. (except for your help! it's the only thing getting me though this day)
Update CONTENT Set title='TESTING NEWS NEW INSERT SCRIPT', user_types='SELFCARE, CAREGIVER, PROVIDERPROVIDER', age_group='CHILD,TEEN, ADULT, SENIORSENIOR', co_morbid='Foot Disease', related_sections='Behavior
Enter content body copy hereASDFASDFASDF
', modified='5/12/2009 3:46:33 PM' where id=335
you can see it's getting rid of the last comma, then adding the last value? and i added multiple items in co_morbid and it's only bringing 1 over. It's probably something so easy, just having a rough day and can't seem to move forward. (except for your help! it's the only thing getting me though this day)
rs.Open "CONTENT", conn, 3, 3
For Each Item in Upload.Form
if Item.Name="user_types" then
user_types=RS("user_types") & Item.Value & ","
end if
if Item.Name="age_group" then
age_group=RS("age_group") & Item.Value & ","
end if
if Item.Name="co_morbid" then
co_morbid=RS("co_morbid") & Item.Value & ","
end if
if Item.Name="related_sections" then
related_sections =RS("related_sections") & Item.Value & ","
end if
Next
sql = "Update CONTENT Set title='" & replace(Upload.form("title"),"'", "`") & "'"
sql = sql & ", user_types='" & Left(user_types, Len(user_types) - 1)& "'"
sql = sql & ", age_group='" & Left(age_group, Len(age_group) - 1)& "'"
sql = sql & ", co_morbid='" & Left(co_morbid, Len(co_morbid) - 1)& "'"
sql = sql & ", related_sections='" & Left(related_sections, Len(related_sections) - 1)& "'"
sql = sql & ", content_type='" & replace(Upload.form("content_type"),"'", "`") & "'"
sql = sql & ", section='" & replace(Upload.form("section"),"'", "`") & "'"
sql = sql & ", sub_section='" & replace(Upload.form("sub_section"),"'", "`") & "'"
sql = sql & ", body_content='" & replace(Upload.form("FCKeditor1"),"'", "`") & "'"
sql = sql & ", modified='" & date() & " " & time()& "'"
sql = sql & " where id="& Upload.form("id")
response.write sql
Set rs = conn.Execute(sql)
new_id=Upload.form("id")
sec= Upload.form("section")
con_type=Upload.form("content_type")
set rs = Nothing
ASKER
got it... sorry to keep posting and figuring it out. LOL. I just couldn't let it go. :) thanks for looking into all this for me. it's been SUPER helpful.
ok... lets take a look at the code... ok ok... so if you copy the code below, what do you get in your final statement? i didn't change much, but i'd like to see what you get...
rs.Open "CONTENT", conn, 3, 3
For Each Item in Upload.Form
if Item.Name="user_types" then
user_types=RS("user_types") & Item.Value & ","
end if
if Item.Name="age_group" then
age_group=RS("age_group") & Item.Value & ","
end if
if Item.Name="co_morbid" then
co_morbid=RS("co_morbid") & Item.Value & ","
end if
if Item.Name="related_sections" then
related_sections =RS("related_sections") & Item.Value & ","
end if
Next
sql = "Update CONTENT Set title='" & replace(Upload.form("title"),"'", "`") & "'"
sql = sql & ", user_types='" & Left(user_types, Len(user_types) - 1) & "'"
sql = sql & ", age_group='" & Left(age_group, Len(age_group) - 1) & "'"
sql = sql & ", co_morbid='" & Left(co_morbid, Len(co_morbid) - 1) & "'"
sql = sql & ", related_sections='" & Left(related_sections, Len(related_sections) - 1)& "'"
sql = sql & ", content_type='" & replace(Upload.form("content_type"),"'", "`") & "'"
sql = sql & ", section='" & replace(Upload.form("section"),"'", "`") & "'"
sql = sql & ", sub_section='" & replace(Upload.form("sub_section"),"'", "`") & "'"
sql = sql & ", body_content='" & replace(replace(Upload.form("FCKeditor1"),"'", "`"),VBCrlF,"<br>") & "'"
sql = sql & ", modified='" & date() & " " & time()& "'"
sql = sql & " where id="& Upload.form("id")
response.write sql
response.end
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you don't have to answer of course, i'm simply curious... ;)
here's the solution.
Open in new window