ASP Edit Form

I have a form that will edit entries in the database. What needs to happen is that with each entry in the database a Radio Button and a Text Field box will appear. The user may only edit one entry per time.

When the user makes their change, the select that radio button. When the user hits submit it fires that and only that entries change to the database.

Any ideas.

Todd
yolishAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jonathonmcCommented:
Construct the form with radio buttons of the same name and textboxes of unique names. Here's some quick example code:
FIELDS: NAME, PHONE, EMAIL
TABLE: MYTABLE
DSN: MYDSN
ASP: WHATEVER.ASP

<%
if not request.form("SUBMITTED") then
%>
<FORM NAME="test" METHOD="POST" ACTION="WHATEVER.ASP">
<INPUT TYPE="RADIO" NAME="vSELECT" VALUE="name">Name
<INPUT TYPE="TEXT" NAME="vNAME"><BR>
<INPUT TYPE="RADIO" NAME="vSELECT" VALUE="phone">Phone
<INPUT TYPE="TEXT" NAME="vNAME"><BR>
<INPUT TYPE="RADIO" NAME="vSELECT" VALUE="email">Email
<INPUT TYPE="TEXT" NAME="vNAME"><BR>
<INPUT TYPE="HIDDEN" NAME="SUBMITTED" VALUE=1>
<INPUT TYPE="SUBMIT">
</FORM>

<%
else
dim conDB
dim cmdDB
set conDB=server.createobject("ADODB.connection")
set cmdDB=server.createobject("ADODB.command")
conDB.open "DSN=MYDSN"
cmdDB.activeconnection=conDB

select case request.form("vSELECT")
case "name"
cmdDB.commandtext="update mytable set name='" & request.form("vName") & "'"
case "phone"
cmdDB.commandtext="update mytable set phone='" & request.form("vPhone") & "'"
case "email"
cmdDB.commandtext="update mytable set email='" & request.form("vEmail") & "'"
case else
response.write "ERROR"
end select

cmdDB.execute
set cmdDB = nothing
conDB.close
set conDB = nothing
end if%>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jonathonmcCommented:
Sorry - in that example the textbox names shoule be vName, vPhone, and vEmail respectivly instead of all vName.
0
yolishAuthor Commented:
My only question to you is, what happens if that list of radio buttons & text boxes are dynamically created from a database. How would you go about creating you case statement then?
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

jonathonmcCommented:
The select statement tests the value of the radio set - the value can be anything that you want, but it's ties to the text field in the select statement. So if you wanted to dynamically change the text fields, name the radio button i where i is a for i=1 to maxnum loop, then run that same loop in your select statement.
0
yolishAuthor Commented:
If you only want one change at a time you need to leave all the names of the radio buttons the same, instead I made a counter on the name of the text field.

This is what I have tried so far

f sAction="edit" Then
      Do While NOT rsLookUp.EOF
      counter=counter+1
            Select Case Request.Form("Lookup_Id")
                  Case 1
                        Response.Write(counter)
                        'sSql2 = "UPDATE Web_Lookup SET lookup_value= '" & sLookup_Value & "' WHERE lookup_id = '" & nFormID & "'"
                        'Vendor.Execute(sSql2)
            End Select
      rsLookUp.MoveNext
      Loop
      'Response.Redirect("/Vendor_relations/search.asp")
End If

With different variations in there
0
jonathonmcCommented:
This should work if the counter is also used (and the same sort options) when the avail. fields are pulled from the DB. Otherwise, you would need to use a more static method, like above.

What is the problem with your example? Does it not work?
0
yolishAuthor Commented:
I have tried this and several variations of this...


If sAction="edit" Then
      Do While NOT rsLookUp.EOF
      counter=counter+1
            Select Case Request.Form("Lookup_Id")
                  Case 1
                        Response.Write(counter)
                        'sSql2 = "UPDATE Web_Lookup SET lookup_value= '" & sLookup_Value & "' WHERE lookup_id = '" & nFormID & "'"
                        'Vendor.Execute(sSql2)
            End Select
      rsLookUp.MoveNext
      Loop
      'Response.Redirect("/Vendor_relations/search.asp")
End If

It appears the issue is how to you put a dynamic entry in the actual case section..

Thanks
0
jonathonmcCommented:
Maybe I'm not understanding the problem, but why not use the numberic value of the recordset in the case section? rsLookUp(0), (1) ...
....using the counter variable?

Otherwise, I must be missing the problem altogether...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.