View Full Version : Pulling info from database

09-07-2010, 02:11 PM
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:

<td><a class='green-button pcb' href='#'><span>Add to Activity Log</span></a></td>
<td><strong><? echo $name; ?></strong></td>

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

09-07-2010, 04:17 PM
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 (http://en.wikipedia.org/wiki/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() (http://api.jquery.com/event.preventDefault/) function. For example:

// do some stuff
return false;

// or....

// do some stuff