| Author |
Topic Search Topic Options
|
l15aRd
Groupie
Joined: 24 May 2002
Location: England
Status: Offline
Points: 121
|
Post Options
Thanks(0)
Quote Reply
Topic: Update a db Field by button Posted: 24 April 2003 at 7:29am |
I want to update a field by a button with an onclick command, is it possible?
here's the code I have
<INPUT TYPE="submit" NAME="x_Link_Aprvd" VALUE="Approve" onclick=
would I have to use Javascript?
Thanx in advance
|
|
|
 |
ultramods
Groupie
Joined: 08 January 2003
Location: Scotland
Status: Offline
Points: 146
|
Post Options
Thanks(0)
Quote Reply
Posted: 24 April 2003 at 8:49am |
You wouldnt have to use javascript if you dont wont to validate anything client side. As you are using the input type submit this is the same as using onclick as when its clicked it will submit the form. you way also want to use the hidden form object to send the record ID. For example:
<form action="approve.asp" method="post">
<INPUT TYPE="hidden" name="recordID" VALUE=<%=recordID%>>
<INPUT TYPE="submit" NAME="x_Link_Aprvd" VALUE="Approve" >
</form>
|
 |
l15aRd
Groupie
Joined: 24 May 2002
Location: England
Status: Offline
Points: 121
|
Post Options
Thanks(0)
Quote Reply
Posted: 24 April 2003 at 8:57am |
|
Cheers m8y will give it a whirl :)
|
|
|
 |
l15aRd
Groupie
Joined: 24 May 2002
Location: England
Status: Offline
Points: 121
|
Post Options
Thanks(0)
Quote Reply
Posted: 24 April 2003 at 9:16am |
done that but it doesn't update the record
<form action="/admin/dt_lk_tbllinksedit.asp?key=" & Server.URLEncode(rs("Link_ID"))" method="post"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td> <INPUT TYPE="hidden" name="link_ID" VALUE=<%=link_ID %>> <input type="Submit" name="x_Link_Aprvd" value="Approved"> </td> </tr> </table> </form>
Basically it's a yes/no field, by default it's set to "NO", I want to change that to "YES" by clicking the approved button.
the field name is "link_aprvd" on the table "tblinks"
|
|
|
 |
ultramods
Groupie
Joined: 08 January 2003
Location: Scotland
Status: Offline
Points: 146
|
Post Options
Thanks(0)
Quote Reply
Posted: 24 April 2003 at 9:40am |
approved= Request.Form("x_Link_Aprvd")
link_ID= Request.Form("link_ID")
IF approved="Approved" THEN
sql="SELECT approved WHERE link_ID=""" " & link_ID & """
Set rs3 = Server.CreateObject("ADODB.Recordset") rs3.Open sql, conn, 3, 3
rs3("approved") = True
rs3.Update
rs3.close set rs3 = nothing conn.close set conn = nothing
END IF
|
 |
ultramods
Groupie
Joined: 08 January 2003
Location: Scotland
Status: Offline
Points: 146
|
Post Options
Thanks(0)
Quote Reply
Posted: 24 April 2003 at 9:42am |
|
In your database where you have data type yes/no change the format of it to True/False.
|
 |
l15aRd
Groupie
Joined: 24 May 2002
Location: England
Status: Offline
Points: 121
|
Post Options
Thanks(0)
Quote Reply
Posted: 24 April 2003 at 10:11am |
|
Right I've changed the format type of the field, and understand the basic principle of the code above, but I'm abit of newbie when it comes to ASP and SQL coding, sorry to be a pain.
|
|
|
 |
ultramods
Groupie
Joined: 08 January 2003
Location: Scotland
Status: Offline
Points: 146
|
Post Options
Thanks(0)
Quote Reply
Posted: 24 April 2003 at 10:31am |
|
Ok, what part of it are you having difficulties with? Try posting any error messages if you are getting any.
|
 |