Welcome to WebmasterWorld Guest from 52.206.226.77

Forum Moderators: ocean10000

Message Too Old, No Replies

Update SQL database with Option Email Address

     
3:57 am on Jul 30, 2009 (gmt 0)

New User

5+ Year Member

joined:July 30, 2009
posts: 6
votes: 0


How to update SQL Database with optional Email address?

Example Update Staff Detail, when update staff email, the person update the email field will have the option, to update with an email address or update record without email address.
So how should i write in my javascript?

Using ASP Classic, javascript and class
language using: VB with ASP classic

My Data retrieve from recordset
<snip>
Thanks in advance.

[edited by: marcel at 8:28 am (utc) on July 30, 2009]
[edit reason] Removed excessive code dump [/edit]

8:29 am on July 30, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:732
votes: 0


Hi HQing and Welcome to Webmasterworld [webmasterworld.com]!

One option for this is the add a checkbox by the email TextBox. If this is checked, update the email in the database, otherwise ignore it.

10:17 am on July 30, 2009 (gmt 0)

New User

5+ Year Member

joined:July 30, 2009
posts: 6
votes: 0


Can you show me an example of the scenario that you have mention.. Thanks

One option for this is the add a checkbox by the email TextBox. If this is checked, update the email in the database, otherwise ignore it.

11:53 am on July 30, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:732
votes: 0


You can add a CheckBox next to your email TextBox in the HTML, like so:
<input type="checkbox" name="chkUpdateEmail" value="1" />&nbsp;Update email address

And when saving the form values to the database, first check to see if the CheckBox has been checked:

If Request.Form("chkUpdateEmail") = 1 Then
' Update the email address
End If
6:10 am on July 31, 2009 (gmt 0)

New User

5+ Year Member

joined:July 30, 2009
posts: 6
votes: 0


So, how to check, because i have a textbox for the email field, so how to show the textbox when i click on the check with Email?
4:09 pm on July 31, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:732
votes: 0


So, how to check, because i have a textbox for the email field, so how to show the textbox when i click on the check with Email?

I think I would use javascript [webmasterworld.com] for this, you can hide or show the TextBox on the checkbox click. But, I would also recommend doing a server side check also before saving to the database