Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Update a db Field by button
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Update a db Field by button

 Post Reply Post Reply
Author
l15aRd View Drop Down
Groupie
Groupie


Joined: 24 May 2002
Location: England
Status: Offline
Points: 121
Post Options Post Options   Thanks (0) Thanks(0)   Quote l15aRd Quote  Post ReplyReply Direct Link To This Post 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

 


DrunkenTechie.net

You can logoff, but you can never leave
Back to Top
ultramods View Drop Down
Groupie
Groupie
Avatar

Joined: 08 January 2003
Location: Scotland
Status: Offline
Points: 146
Post Options Post Options   Thanks (0) Thanks(0)   Quote ultramods Quote  Post ReplyReply Direct Link To This Post 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>

Back to Top
l15aRd View Drop Down
Groupie
Groupie


Joined: 24 May 2002
Location: England
Status: Offline
Points: 121
Post Options Post Options   Thanks (0) Thanks(0)   Quote l15aRd Quote  Post ReplyReply Direct Link To This Post Posted: 24 April 2003 at 8:57am
Cheers m8y will give it a whirl :)

DrunkenTechie.net

You can logoff, but you can never leave
Back to Top
l15aRd View Drop Down
Groupie
Groupie


Joined: 24 May 2002
Location: England
Status: Offline
Points: 121
Post Options Post Options   Thanks (0) Thanks(0)   Quote l15aRd Quote  Post ReplyReply Direct Link To This Post 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"


DrunkenTechie.net

You can logoff, but you can never leave
Back to Top
ultramods View Drop Down
Groupie
Groupie
Avatar

Joined: 08 January 2003
Location: Scotland
Status: Offline
Points: 146
Post Options Post Options   Thanks (0) Thanks(0)   Quote ultramods Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
ultramods View Drop Down
Groupie
Groupie
Avatar

Joined: 08 January 2003
Location: Scotland
Status: Offline
Points: 146
Post Options Post Options   Thanks (0) Thanks(0)   Quote ultramods Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
l15aRd View Drop Down
Groupie
Groupie


Joined: 24 May 2002
Location: England
Status: Offline
Points: 121
Post Options Post Options   Thanks (0) Thanks(0)   Quote l15aRd Quote  Post ReplyReply Direct Link To This Post 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.

DrunkenTechie.net

You can logoff, but you can never leave
Back to Top
ultramods View Drop Down
Groupie
Groupie
Avatar

Joined: 08 January 2003
Location: Scotland
Status: Offline
Points: 146
Post Options Post Options   Thanks (0) Thanks(0)   Quote ultramods Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.