Print Page | Close Window

Update a db Field by button

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=2054
Printed Date: 29 March 2026 at 9:43am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Update a db Field by button
Posted By: l15aRd
Subject: Update a db Field by button
Date 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

 



-------------

http://www.drunkentechie.net - DrunkenTechie.net

You can logoff, but you can never leave



Replies:
Posted By: ultramods
Date 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>



Posted By: l15aRd
Date Posted: 24 April 2003 at 8:57am
Cheers m8y will give it a whirl :)

-------------

http://www.drunkentechie.net - DrunkenTechie.net

You can logoff, but you can never leave


Posted By: l15aRd
Date 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"



-------------

http://www.drunkentechie.net - DrunkenTechie.net

You can logoff, but you can never leave


Posted By: ultramods
Date 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



Posted By: ultramods
Date 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.


Posted By: l15aRd
Date 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.

-------------

http://www.drunkentechie.net - DrunkenTechie.net

You can logoff, but you can never leave


Posted By: ultramods
Date 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.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net