Let’s start with some basic tips, nothing to complex 
Your click-event on the edit button:
- Not that there is anything wrong with what you have written, it’s nicer to write it as below (you may ignore the new-lines and the tabs, it just reads easier :-))
If you have to change multiple attributes of an element, you can just group them, as you can see below
$('.edit').click(function(){
$('#do').attr({
'value': 'Submit',
'class': 'submit'
});
});
- My code is a bit more clean now, but it can be cleaner, so step 2: Seeing as we want to change the same button we’ve just clicked on, there is no need to search the DOM again. We can just replace $(‘#do’) with $(this). $(this) is a reference to the element we’ve just clicked on, in our case, the “edit”-button.
$('.edit').click(function(){
$(this).attr({
'value': 'Submit',
'class': 'submit'
});
});
- Seeing as we are changing the class of the button to “submit”, there is actually no use anymore to have the “edit” click-event anymore on our button, so we should unbind it, like so:
$('.edit').click(function(){
$(this).attr({
'value': 'Submit',
'class': 'submit'
});
$(this).unbind('click');
});
Ok, the code is nice and neat, lets have a look at your problem!
The problem you’re facing is that the button doesn’t execute the “click”-event of the “submit”-button. That’s normal… I assume you’ve added the “$(‘.submit’).click(function(e){ // code });” code in the onload-function. Let me explain the problem:
- When the browser reads/executes your code it will look for any element with the class “submit” and place a “click”-event on them. HOWEVER when your code is executed, there is no element with the class “submit”, because you’re putting (changing, in your case) the class “submit” on an element after your code was executed. (I hope this makes sense, it’s much easier explaining it in my own language :p)
So what you could do is, place the code of the submit-click inside the edit-click, like so:
$('.edit').click(function(){
$(this).attr({
'value': 'Submit',
'class': 'submit'
});
$(this).unbind('click');
$(this).click(function(e){
alert(this.form.id);
info = $(this.form.id).serialize();
info = info + '&do=' + $('#do-').val();
e.preventDefault();
$.ajax({
type: 'POST',
url: 'ajax.saveEvent.php',
data: info,
success: function(data){
$('#eventFormDiv').html(data);
}
});
});
});
Notice that I have changed “$(‘.submit’)” with “$(this)”. The difference between them is that I’m only placing the new click-event on the current button.
It would also be a bit nicer if you would create a seperate function for the “submit”-click event, but not necessary.
If something is still unclear, feel free to ask!