onclick funtion to run sql query and update records in background

i m having a dating site, wherein there is link view contacts, once clicked it shows contact details of respective member.
now as its a membership site, paid members are alotted limited number of contact views, after that they are restricted.
Now i m having a link View contacts which on click shows popup box with details, i m using javascript: termsFunction2(); for this... now what i want is an onclick function like when the link is clicked a sql query for update should run in background and updates the no. of contacts viewed in database.
the view contact popup box opens without page refresh....

below is the code i m using for pop up
		@import "popup/Assets/LightFace.css";
	<link rel="stylesheet" href="popup/Assets/lightface.css" />
	<script src="popup/mootools.js"></script>	
	<script src="popup/mootools-more-drag.js"></script>
	<script src="popup/Source/LightFace.js"></script>
    <script src="popup/Source/LightFace.IFrame.js"></script>
	 	function formFunction() {
	 		return new LightFace({
	 			title: $('demo1title').value,
	 			content: $('demo1content').value,
				draggable: true
	 			function termsFunction2()
	  		box = new LightFace({ 
	 			title: 'Contact Details of Bhavin Patel (S1078)', 
				width: 700,
				height: '100%',
	  			content: '<table><tr><td>Mobile</td><td>********** Upgrade Membership to view Mobile No.</td></tr><tr><td>Landline</td><td>+91-79-</td></tr><tr><td>Email Address</td><td>bhavin_2511@yahoo.com</td></tr><tr><td>Name of Contact Person</td><td>Tarak Patel</td></tr><tr><td>Relationship with the member</td><td>Self</td></tr><tr><td>Convenient Time to Call</td><td>1&nbsp;AM to 2&nbsp;PM</td></tr><tr><td>Contact Numbers Balance</td><td>Viewed - 0&nbsp;|&nbsp;Balance - 100</td></tr></table>',
	 			buttons: [
						title: 'Close', 
						event: function() { this.close(); },
						color: 'blue'

 <a href="javascript: termsFunction2();">View Phone No.</a>

Open in new window

Who is Participating?
I would just create an ajax function to update the database based off the onclick event.
Your client-size Javascript will not be able to directly access your database. You will need to execute an Ajax request to your web server, at which point you can update your database and return the new value to the user. Then, you will be able to modify the DOM to reflect the changes.
global_expert_adviceAuthor Commented:
did the trick.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.