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 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2010
    Posts
    74
    Thanks
    12
    Thanked 0 Times in 0 Posts

    A Little Help Please...

    Hello all,

    I have a page that includes the following code:

    Code:
    $(document).ready(function(){
    	$('addActivity').click(function() {
    	alert('test');
    	});
    	$("form#exercise").submit(function() {
    	// we want to store the values from the form input box, then send via ajax below
    	var activity     = $('#activity').attr('value');
    		$.ajax({
    			type: "POST",
    			url: "newActiveProc.php",
    			data: "activity="+ activity +"&func=search",
    			success: function(msg){
    				$("span#results").html(msg);
    
    			}
    		});
    	return false;
    	});
    
    });
    This code, coupled with a table on the page, should allow the user to add an activity to their personal table. First, they search for an activity then click 'Submit'. The user is then presenting with a list of more specific criteria based on the activity they chose. For example, if the user chooses 'Sports' from the available list and clicks 'Submit', they are then presented with a specific lists of sports (stored in a database) such as basketball, football, and so on. Next to each item in the specific list is a button that is meant to be used to add the activity to the user's table. For example:

    [Add to table] Basketball
    [Add to table] Football
    [Add to table] Baseball

    However, the 'Add to table' button is not working. I'm thinking that I need to add some type of working function to it. If that is right, can someone point me in the right direction? Based on the code I pasted at the beginning of this post, does anyone have any suggestions? Thanks in advance.

  • #2
    New Coder
    Join Date
    Aug 2010
    Posts
    74
    Thanks
    12
    Thanked 0 Times in 0 Posts
    I have another question: In the code above, doesn't a parameter have to be in the function (parameter) in order to pass the values to the table?

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    This is jQuery code. You'll have more luck getting answers to questions involving jQuery in the Javascript Frameworks forum.

    Regarding your question: you mean this bit?:

    Code:
    $('addActivity').click(function() {
    	alert('test');
    	});
    I'm assuming "addActivity" is the ID of a button or a link or something? If so, you need the "#" ID selector in front of it:

    Code:
    $('#addActivity').click(function() {
    	alert('test');
    	});

  • Users who have thanked Spudhead for this post:

    dj262501 (09-07-2010)

  • #4
    New Coder
    Join Date
    Aug 2010
    Posts
    74
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Instead of alerting the user, is there a way I can add their selection to the table within the page?


  •  

    Posting Permissions

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