?
Solved

Hyperlink onclick write to database

Posted on 2005-02-28
10
Medium Priority
?
317 Views
Last Modified: 2006-11-17
Hi there,

I want to write to the database when a hyperlink is clicked

ie
<a href="mailto:joebloggs@joebloggs.com">Email</a>

<%
      set conn = server.createobject("adodb.connection")
      conn.open MM_Directory_STRING
      SQL = "INSERT INTO webDirectoryEmail(CompanyID) VALUES ('" & (StandardResults.Fields.Item("Member_ID").Value) &"')"
      conn.execute SQL
      conn.close
%>

Many thanks

Max
0
Comment
Question by:MaximusMeridus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 7

Expert Comment

by:rohanbairat3
ID: 13421001
You can create a seperate page which has the code to write to the database ... and on  hyperlink click write a javascript to send the information to be written to the other page.
0
 
LVL 13

Accepted Solution

by:
nurbek earned 800 total points
ID: 13421038
you need a form submission

try this

<%
If LCase(Request.ServerVariables("REQUEST_METHOD")) = "post" Then
Email = Request.Form("email")
     set conn = server.createobject("adodb.connection")
     conn.open MM_BCCBDirectory_STRING
     SQL = "INSERT INTO webDirectoryEmail(CompanyID) VALUES ('" & email) &"')"
     conn.execute SQL
     conn.close
End If
%>
<form name="form1" method="post" action="">
<a href="#" onClick="document.form1.submit();">Email
  </a>
  <p>
    <input name="email" type="hidden" id="email" value="my@email.com">
</p>
</form>
0
 
LVL 7

Expert Comment

by:rohanbairat3
ID: 13421076
<a href="javascript:SendInfo('info')">
function SendInfo(info)
{

        URL =  "page.asp?Info="+info
  parent.location = URL
}

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:MaximusMeridus
ID: 13421154
Hi there,

I did think of this, however I wanted to stay on the same page and if a page pops up it must close afterward immediately. If there no way it can be done on the same page?

Max
0
 
LVL 7

Expert Comment

by:rohanbairat3
ID: 13421185
The Solution provided by nurbek  should work ...

Are you doing other things on the form ....

And yes it is possible to open a popup page and hide it from user and close it once the task is done ...

let me know if you need some code for that..

-rohan
0
 
LVL 13

Expert Comment

by:nurbek
ID: 13421192
have you tried mine?

you may define the form action on the same page
<form name="form1" method="post" action="mypage.asp">

and put the code above (top) of your asp page
0
 
LVL 5

Assisted Solution

by:web4net
web4net earned 800 total points
ID: 13421307
I agree with rohanbairat3 .

I would do it a little different. This way, the link works even in older browsers.

=========================
   Link Pages
=========================

<html>
<head>
<script language="JavaScript">
function SendInfo(url,memberid)
{
       parent.location = "linksmanager.asp?url="+url+"&memberid="+memberid
}
</script>
</head>
<body>
<a href="mailto:joebloggs@joebloggs.com" onclick="SendInfo(this.href,'<%=Member_ID%>')">
</body>
</html>

=========================
   Links Manager
=========================
<%
     set conn = server.createobject("adodb.connection")
     conn.open MM_Directory_STRING
     SQL = "INSERT INTO webDirectoryEmail(CompanyID) VALUES ('" & Request.QueryString("Member_ID") &"')"
     conn.execute SQL
     conn.close

     Response.Redirect Request.QueryString("url")
%>
0
 
LVL 5

Expert Comment

by:web4net
ID: 13421323
wait ... Use IFRAME
0
 
LVL 9

Assisted Solution

by:cb1393
cb1393 earned 400 total points
ID: 13421354
Do you mean you want the page to not be refreshed? You might try this:

<IMG SRC="" HEIGHT="1PX" WIDTH="1PX" ID="DB_IMG">
<A HREF="#" onClick="document.all.DB_IMG.src='write_to_db.asp?email=my@email.com'">Write to the database</A>

<-------------------------------- Place the following in write_to_db.asp -------------------------------->
<%
email = Request.QueryString("email")
If email <> "" Then
     set conn = server.createobject("adodb.connection")
     conn.open MM_BCCBDirectory_STRING
     SQL = "INSERT INTO webDirectoryEmail(CompanyID) VALUES ('" & email) &"')"
     conn.execute SQL
     conn.close
End If
%>
0
 
LVL 5

Assisted Solution

by:web4net
web4net earned 800 total points
ID: 13421371
The following way you never leave the page.

=========================
   Link Pages
=========================

<html>
<head>
<script language="JavaScript">
function SendInfo(url,memberid)
{
       document.getElementById(LinkIFrame).src='linksmanager.asp?url='+url+'&memberid='+memberid;
}
</script>
</head>
<body>
<a href="mailto:joebloggs@joebloggs.com" onclick="SendInfo(this.href,'<%=Member_ID%>')">

<iframe id="LinkIFrame"
  name="LinkIFrame"
  style="width:0px; height:0px; border: 0px"
  src="blank.html"></iframe>

</body>
</html>

=========================
   linksmanager.asp
=========================
<%
     set conn = server.createobject("adodb.connection")
     conn.open MM_Directory_STRING
     SQL = "INSERT INTO webDirectoryEmail(CompanyID) VALUES ('" & Request.QueryString("Member_ID") &"')"
     conn.execute SQL
     conn.close

     Response.Redirect Request.QueryString("url")
%>
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question