Hey dudes and dudettes!
First, here’s the code I’m trying to get through:
function addSponsors(s) {
var sn = prompt("New sponsors name?");
if(sn !=null) {
jQuery.post('../wp-content/plugins/NewLife-EventCalendar/php/addSponsor.php',{sponsorName: sn}, function(r) {
if(r) {
jQuery('#sponsorList').append('\\
<tr id="row' + r + '">\\
<td class="id">' + r + '</td>\\
<td class="name">' + sn + '</td>\\
<td><a onClick="editSponsor('+r+')">Edit</a></td>\\
<td><a onClick="deleteSponsor('+r+')">Delete</a></td>\\
</tr>\\
');
jQuery('#row'+r).fadeIn(function() {
jQuery('#sponsorList tr').each(function(i) {
jQuery('#sponsorList tr').removeClass('odd');
if(++i %2 == 0) {
jQuery('#sponsorList tr').addClass('odd');
}
})
})
}
})
}
}
It’s a function for an event calendar, for the user to be able to add a “sponsor” for the event. They type the name into the prompt, and it takes the value, posts it to the given PHP script and then returns the value of the inserted id. updates the table that holds all the sponsor information.
The 2 problems I’m running into, are these:
- The new table row dosen’t fade in. It just shows up.
- I have every other row in the table highlighted. I can’t figure out what needs to be done to check to see if the newly added table row is an “odd” or “even” row. If it’s odd, then it add’s the ‘odd’ class to the row to make it highlighted.
Any suggestions?
Thanks!