gpt4 book ai didi

php - 类型错误 : 'checkValidity' called on an object that does not implement interface HTMLTextAreaElement

转载 作者:行者123 更新时间:2023-12-01 05:25:03 25 4
gpt4 key购买 nike

我遇到此错误,并且由于此错误而无法发送电子邮件。我在 opencart v2.0.1.1 中添加了一个新的扩展生日提醒我已经搜索了该错误,但无法解决它。请帮忙。该文件的代码是这样的。

<form class="form mailForm">
<div class="row form-group" style="text-align: center; font-size: 18px;">
<div class="col-xs-4">
<div class="brCustomerMailInfo">
<label>To: </label>
<strong><?php if(!empty($customerInfo['email'])) echo $customerInfo['email']; ?></strong>
<input type="hidden" name="customer_id" value="<?php if(!empty($customerInfo['customer_id'])) echo $customerInfo['customer_id']; ?>" />
<input type="hidden" name="to_mail" value="<?php if(!empty($customerInfo['email'])) echo $customerInfo['email'];?>" />
</div>
</div>
<div class="col-xs-4">
<div class="brCustomerMailInfo">
<label>Born:</label>
<strong><?php if(!empty($customerInfo['birthday_date'])){
echo $customerInfo['birthday_date'];
}
?></strong>
</div>
</div>
<div class="col-xs-4">
<div class="brCustomerMailInfo">
<label>Age:</label>
<strong>
<?php if(!empty($customerInfo['birthday_date'])) {;
$now = new DateTime("now");
if (strpos($customerInfo['birthday_date'],'/') !== false) {
echo floor((time()-strtotime(str_replace('/', '-', $customerInfo['birthday_date'])))/(365*60*60*24)) ;
} else {
echo floor((time()-strtotime($customerInfo['birthday_date']))/(365*60*60*24)) ;
}
}?>
</strong>
</div>
</div>
</div>
<div class="row form-group">
<div class="col-xs-3">
<h5><strong><?php echo $discount_code_text ?></strong></h5>
</div>
<div class="col-xs-9">
<strong><?php echo $discount_code?></strong>
<input type="hidden" class="brSmallField form-control" name="discount_code" value="<?php echo $discount_code?>">
</div>
</div>
<div class="row form-group">
<div class="col-xs-3"><h5><strong><span class="required">* </span><?php echo $type_of_discount;?></strong></h5></div>
<div class="col-xs-3">
<select class="form-control" name="discount_type" >
<option value="P"><?php echo $percentage_text?></option>
<option value="F" <?php if(!empty($data['BirthdayReminder']['discount_type']) && $data['BirthdayReminder']['discount_type'] == "F") echo "selected";?>><?php echo $fixed_amount; ?></option>
</select>
</div>
</div>
<div class="row form-group">
<div class="col-xs-3"><h5><strong><span class="required">* </span><?php echo $discount_text;?></strong></h5></div>
<div class="col-xs-3">
<div class="input-group">
<input type="text" class="brSmallField form-control" name="discount" value="<?php if(!empty($data['BirthdayReminder']['discount'])) echo $data['BirthdayReminder']['discount']; ?>">
<span class="input-group-addon" >%</span>
</div>
</div>
</div>
<div class="row form-group">
<div class="col-xs-3"><h5><strong><span class="required">* </span><?php echo $total_amount; ?></strong></h5></div>
<div class="col-xs-3">
<div class="input-group">
<input type="text" class="brSmallField form-control" name="total_amount" value="<?php echo $data['BirthdayReminder']['total_amount'] ?>">
<span class="input-group-addon" ><?php echo $currency ?></span>
</div>
</div>
</div>
<div class="row form-group">
<div class="col-xs-3"><h5><strong><span class="required">* </span>Subject:</strong></h5></div>
<div class="col-xs-3">
<input placeholder="Mail subject" type="text" id="subject" class="form-control" name="subject" value="<?php if(!empty($data['BirthdayReminder']['subject'])) echo $data['BirthdayReminder']['subject']; else echo $default_subject; ?>" />
</div>
</div>
<div class="row form-group">
<div class="col-xs-3"><h5><strong><span class="required">* </span><?php echo $user_email; ?></strong></h5></div>
<div class="col-xs-9">
<textarea class="form-control" id="giftMessage">
<?php if(!empty($customerInfo)) {
$wordTemplates = array("{firstname}", "{lastname}", "{discount_code}");
$words = array($customerInfo['firstname'], $customerInfo['lastname'], $discount_code);

if(!empty($data['BirthdayReminder']['message'][$customerInfo['language_id']])) {
$message = str_replace($wordTemplates, $words,$data['BirthdayReminder']['message'][$customerInfo['language_id']]);
echo $message;
} else {
$default_message = str_replace($wordTemplates, $words, $default_message);
echo $default_message;
}
}?>
</textarea>
</div>
</div>
<div class="row form-group">
<div class="col-xs-4">&nbsp;</div>
<div class="col-xs-4" style="text-align: center"><button class="btn btn-lg btn-primary" id="sendGift"><?php echo $send_gift_button; ?></button></div>
</div>
</form>
<script>
var gettingOptions = function () {
$('textarea[id="giftMessage"]').each(function(index, element) {
$('#'+element.id).summernote({
height:150
});

$('.btn#sendGift').on('click', function(e){
e.preventDefault();
var currentYear = new Date().getFullYear();
var errorInput = false;

if(!$('input[name="subject"]').val()){
e.preventDefault();
errorInput = true;
$('input[name="subject"]').css({'background':'#f2dede'});
}

if(!validateNumber($('input[name="discount"]'), e)) {
errorInput = true;
}

if(!validateNumber($('input[name="total_amount"]'), e)) {
errorInput = true;
}

if(!errorInput) {
var isSentGift = false;
var lastGift = "<?php if(isset($customerInfo['last_gift_date'])){ $date = explode('-', $customerInfo['last_gift_date']); echo $date[0]; } else { echo '0';}?>";
if(currentYear == lastGift){
isSentGift= true;
}

sentAgain = true;

if(isSentGift) {
var last_gift_date = "<?php if(!empty($customerInfo['last_gift_date'])) {
echo $customerInfo['last_gift_date'];
}
?>";
var sentAgain=confirm("A gift is sent to this customer on " + last_gift_date + ". Do you want to sent this again?");
}

if(sentAgain){
$.ajax({
url: 'index.php?route=<?php echo $modulePath;?>/sendGift&token=' + getURLVar('token') ,
dataType: 'html',
data:{
discount_code: $("input[name='discount_code']").val(),
discount: $("input[name='discount']").val(),
total_amount: $("input[name='total_amount']").val(),
discount_type: $("select[name='discount_type']").val(),
customer_id: $("input[name='customer_id']").val(),
to_mail: $("input[name='to_mail']").val(),
subject: $("input[name='subject']").val(),
gift_message: $('#'+element.id).summernote('code') },
type: 'POST',
dataType:"json",
success: function(data){
$('.messageHasBeenSent').show().delay(3000).fadeOut(600);
$('.btn.btn-link.active').click();
}
});
}
$("#sendEmailModal").modal('hide');
}
else {
e.preventDefault();
}
});
});
};

$("#sendEmailModal").on('shown.bs.modal', function (e) {
gettingOptions();
});

if($('select[name="discount_type"]').val() == 'P'){
$('#percentageAddonForm').show();
} else {
$('#currencyAddonForm').show();
}

$('select[name="discount_type"]').on('change', function(e){
if($(this).val() == 'P') {
$('#percentageAddonForm').show();
$('#currencyAddonForm').hide();

} else {
$('#currencyAddonForm').show();
$('#percentageAddonForm').hide();
}
});

function validateNumber(input, theEvent) {
var regex = /[0-9]|\./;
if(!regex.test(input.val())) {
input.css({'background':'#f2dede'});
return false;
} else {
return true;
}
}
</script>

最佳答案

我已经解决了这个问题!

if(sentAgain){
$.ajax({
url: 'index.php?route=<?php echo $modulePath;?>/sendGift&token=' + getURLVar('token') ,
dataType: 'html',
data:{
discount_code: $("input[name='discount_code']").val(),
discount: $("input[name='discount']").val(),
total_amount: $("input[name='total_amount']").val(),
discount_type: $("select[name='discount_type']").val(),
customer_id: $("input[name='customer_id']").val(),
to_mail: $("input[name='to_mail']").val(),
subject: $("input[name='subject']").val(),
gift_message: $('#'+element.id).summernote('code') },
type: 'POST',
dataType:"json",
success: function(data){
$('.messageHasBeenSent').show().delay(3000).fadeOut(600);
$('.btn.btn-link.active').click();
}
});
}

这是 ajax 调用,这一行导致了问题

gift_message: $('#'+element.id).summernote('code')

所以我用这个改变它

gift_message: $('#giftMessage').val()

在这种情况下该元素未定义。

关于php - 类型错误 : 'checkValidity' called on an object that does not implement interface HTMLTextAreaElement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40366974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com