我的初始表单计算变量 $finallowamount 和 $finalhighamount,但我似乎无法将这些变量的值传递给我的 jQuery 联系人 javascript 文件(下面的代码)。任何帮助将不胜感激。谢谢。
$(function() {
$('a.email').click(function(event) {
event.preventDefault();
$('body').append('<div id="popupshadow"></div><div id="popup"></div>');
$('#popupshadow').css({opacity:0}).animate({opacity:0.7},1000);
$('#popup').css({opacity:0}).delay(1200).animate({opacity:1},800);
$('#popup').html('<form class="contact" action="#" method="post"><table class="contact"><tr><td class="input-name">Name:</td><td><input type="text" name="name" size="25" /></td></tr><tr><td class="input-email">Email:</td><td><input type="email" name="email" size="25" /></td></tr><tr><td class="input-phone">Phone:</td><td><input type="phone" name="phone" size="25" /></td></tr><tr><td></td><td><input type="submit" value="Send" /></td></tr></table><input type="hidden" name="to" value="noahldavis@gmail.com"></form>');
$('form.contact').submit(function(event) {
$('form.contact td').css('color','#000000');
var name = $('form.contact input[name="name"]').val();
var email = $('form.contact input[name="email"]').val();
var phone = $('form.contact input[name="phone"]').val();
var to = $('form.contact input[name="to"]').val();
var valid = true;
if(name == "")
{
valid = false;
$('td.input-name').css('color','#FF0000');
}
if(email == "" && phone == "")
valid = false;
if(email == "")
$('td.input-email').css('color','#FF0000');
if(phone == "")
$('td.input-phone').css('color','#FF0000');
var message = 'message';
var paymentstreamtype = $("#ssq_rc_general input[type=radio]:checked").val();
var finallowamount = $("#finallowamount").html();
var finalhighamount = $("#finalhighamount").html();
if(valid) {
$.ajax({url : 'contact.php',
data : {name : name,
email : email,
phone : phone,
message : message,
paymentstreamtype : paymentstreamtype,
finallowamount : finallowamount,
finalhighamount : finalhighamount,
to : to},
type : 'post',
success : function(data) {
$('#popup').html('<p style="text-align:center;">Your message has been sent.</p>');
$('#popup, #popupshadow').delay(1000).animate({opacity:0},500).delay(500).queue(function() { $(this).remove(); });
}
});
}
event.preventDefault();
return false;
});
$('#popupshadow, a.cancel').click(function(event) {
$('#popup, #popupshadow').animate({opacity:0},500).delay(500).queue(function() { $(this).remove(); });
});
});
});