Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update databae and return to same page

Status
Not open for further replies.

meltingpot

Technical User
May 11, 2004
118
GB
I have the following code to update a database field.

Head .........................................................

<% If Request.QueryString("update") <> "" Then %>
<%
strConnectionString = "dsn=jsastc"
Set cnn = Server.CreateObject("ADODB.Connection")
cnn.Open strConnectionString
strSQL = "UPDATE Applications SET Applications.StatusCode = '"&(Request.QueryString("update"))&"' WHERE

ApplicationID = "&(Request.QueryString("ApplicationID"))&""
cnn.Execute strSQL,,adCmdText + adExecuteNoRecords
cnn.Close
%>
<% Else %>
<% End If %>

Body ..........................................................

<A href="course_allocate.asp?ApplicationID=<%=(course_pending.Fields.Item("ApplicationID").Value)%>&CourseID=<%=

(found_course.Fields.Item("CourseID").Value) %>&update=Accepted"><img src="../images/accpet2.gif" width="40"

height="20" border="0"></A>

-----------------------------------
please notice that it simply changes the original value to 'Accepted' >&update=Accepted.
I would like to replace this with a varibal value from a dropdown box .

The code for the box is

Drop Down ...............................
<select name="coursechange" class="bodytext" id="coursechange">
<%
While (NOT getstatus.EOF)
%>
<option value="<%=(getstatus.Fields.Item("Status").Value)%>"><%=(getstatus.Fields.Item("Status").Value)%></option>
<%
getstatus.MoveNext()
Wend
If (getstatus.CursorType > 0) Then
getstatus.MoveFirst
Else
getstatus.Requery
End If
%>
</select>
-----------------------------------

Can anybody help
Cheers
 
Unsure what you're exactly trying to do.

If the form has been posted you can reference the selected value from the dropdown list as request.form("coursechange")

If the form hasn't been posted and you're trying to change something on the page based on the selection made in the dropdown list, you'll need to write a javascript function to do that.

If you're trying to change the selected value of the dropdown list to be the same as the one selected when the form was submitted, you just need a little addition to your loop
Code:
While (NOT getstatus.EOF)
%>
                        <option value="<%=(getstatus.Fields.Item("Status").Value)%>"[COLOR=green]<%if getstatus.Fields.Item("Status").Value=request.form("coursechange") then response.write(" selected") end if%>[/color]><%=(getstatus.Fields.Item("Status").Value)%></option>
                        <%
  getstatus.MoveNext()
Wend
 
Hi ecwcee ...

Trying to get the variable from the drop down box

=(getstatus.Fields.Item("Status").Value)

and then click a button and the record 'Applications.StatusCode ' is update with that varibale, this then returns to the same page :)








-
 
Ok, well I haven't worked with Applications.StatusCode before, but as I was saying when the form is submitted the value of the dropdown list becomes available to you as request.form("coursechange")... maybe you can try setting it with that?
Code:
If request.form("coursechange")<>"" Then
    Applications.StatusCode = request.form("coursechange")
End If
As I said, I haven't worked with Applications.StatusCode so I can only hope that it's that simple, hopefully that gives you a general idea to work with.
 
Hi ... Applications.StatusCode: this is simply the table and field name from the database.

Ill try your sugestion and get back.. many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top