Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2010
    Posts
    74
    Thanks
    12
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    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
    });


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •