...

View Full Version : A Little Help Please...



dj262501
09-02-2010, 04:23 AM
Hello all,

I have a page that includes the following 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.

dj262501
09-02-2010, 05:59 AM
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?

Spudhead
09-02-2010, 02:21 PM
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?:


$('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:


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

dj262501
09-07-2010, 04:03 PM
Instead of alerting the user, is there a way I can add their selection to the table within the page?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum