Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-07-2010, 01:11 PM   PM User | #1
dj262501
New Coder

 
Join Date: Aug 2010
Posts: 74
Thanks: 12
Thanked 0 Times in 0 Posts
dj262501 is an unknown quantity at this point
Pulling info from database

Quote:
Originally Posted by dj262501 View Post
Hello all,

I'm not sure if I'm in the right place, but I need help. I have a php page that connects to a database and and pulls info from a second page. When the user selects an activity, they see a green button that says 'Add to Activity Log'. The problem is that right now I have the code setup like this:

Code:
<tr>
    	<td><a class='green-button pcb' href='#'><span>Add to Activity Log</span></a></td>
        <td><strong><? echo $name; ?></strong></td>
	</tr>
I know the href is not supposed to be there, but I don't know what to do with it to enable the user to add the activity to their log. Any ideas?
In addition, I do not want the page to refresh. I just want the information added to the table at the bottom of the page after the user makes their selection. Any informaton would be helpful at this point.

Thank You
dj262501 is offline   Reply With Quote
Old 09-07-2010, 03:17 PM   PM User | #2
Spudhead
Senior Coder

 
Spudhead's Avatar
 
Join Date: Jun 2002
Location: London, UK
Posts: 1,856
Thanks: 8
Thanked 110 Times in 109 Posts
Spudhead is on a distinguished road
Well, ideally the anchor should link to a page that allows the user to complete that functionality, without requiring javascript. This is the notion of Progressive Enhancement.

To prevent the anchor taking the user to that page when it's clicked, you can simply return false from your event handler, or use jQuery's preventDefault() function. For example:

Code:
$('a.green-button').click(function(){
	// do some stuff
	return false;
});

// or....

$('a.green-button').click(function(event){
	event.preventDefault();
	// do some stuff
});
Spudhead is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:07 AM.


Advertisement
Log in to turn off these ads.