remp
11-22-2010, 04:36 AM
Hello, i got this code:
$(function() {
// These first three lines of code compensate for Javascript being turned on and off.
// It simply changes the submit input field from a type of "submit" to a type of "button".
var paraTag = $('input#submit').parent('p');
$(paraTag).children('input').remove();
$(paraTag).append('<input type="button" name="submit" id="submit" value="Email Us Now!" />');
$('#main input#submit').click(function() {
$('#main').append('<img src="images/ajax-loader.gif" class="loaderIcon" alt="Loading..." />');
var name = $('input#name').val();
var email = $('input#email').val();
var comments = $('textarea#comments').val();
var phone = $('input#phone').val();
$.ajax({
type: 'post',
url: 'mail/contact.php',
data: 'name=' + name + '&email=' + email + '&comments=' + comments + '&phone=' + phone ,
}
}); // end ajax
});
});
which i use to process a form, now my questions is:
how can i perhaps give a form an ID and give it a different url on the $.ajax variable according to the form id???
$(function() {
// These first three lines of code compensate for Javascript being turned on and off.
// It simply changes the submit input field from a type of "submit" to a type of "button".
var paraTag = $('input#submit').parent('p');
$(paraTag).children('input').remove();
$(paraTag).append('<input type="button" name="submit" id="submit" value="Email Us Now!" />');
$('#main input#submit').click(function() {
$('#main').append('<img src="images/ajax-loader.gif" class="loaderIcon" alt="Loading..." />');
var name = $('input#name').val();
var email = $('input#email').val();
var comments = $('textarea#comments').val();
var phone = $('input#phone').val();
$.ajax({
type: 'post',
url: 'mail/contact.php',
data: 'name=' + name + '&email=' + email + '&comments=' + comments + '&phone=' + phone ,
}
}); // end ajax
});
});
which i use to process a form, now my questions is:
how can i perhaps give a form an ID and give it a different url on the $.ajax variable according to the form id???