当我选择下拉列表时,我需要在textarea中自动填充一些帮助。我试过它,它在jsfiddle上工作得很完美,但是当我在我的网络托管上传脚本时,没有任何事情发生。我不知道我错在哪里。
<?php
$subject = $_POST['EmailSubject'];
$message = $_POST['EmailBody'];
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: SocialDealers <admin@admin.com>' . "\r\n";
$emailList = explode("\n",$_POST['EmailList']);
if(count($emailList) > 0){
foreach($emailList as $to){
$to = trim($to);
$sent = mail($to,$subject,$message,$headers);
if ($sent){
echo "<p>Sent: $to</p>";
}
else{
echo "<p>Not Sent: $to</p>";
}
}
}
else{
echo "<p>No email addresses</p>";
}
?>
<html>
<head>
<script>
var contentToInsert = 'Hi Amey';
$( "#listbox" ).change(function() {
if ($( "#listbox" ).val() == '2') {
$("#EmailBody").html(contentToInsert);
} else {
$("#EmailBody").html("");
}
});
</script>
</head>
<center>
<form method="post">
<br><strong>PHP Email Sender</strong><br><br><br>
Email List<br>
<textarea name="EmailList" placeholder="email@email.com (New Email Each Line)" rows="20" cols="50"></textarea><br><br>
Subject<br>
<input type="text" name="EmailSubject" placeholder="Your Subject Goes Here"><br><br>
Select Automated HTML Content<br>
<select id="listbox">
<option id="option1">Select Offers...</option>
<option id="option2">1</option>
<option id="option3">2</option>
</select>
<br><br>
Body<br>
<textarea name="EmailBody" id="EmailBody" placeholder="Write your content (HTML Accepted)" rows="20" cols="50"></textarea><br><br>
<input type="submit" value="Submit!">
</form><br><br>
</center>
</html>
我不知道我错过了哪里,但我整天都在努力找出问题而且我什么都不懂。此外,如果有可能我希望选择文本来自另一个文本文件。
示例:
答案 0 :(得分:0)
如果它在Jsfiddle
而非托管环境中工作,那么您需要确保在代码中引用了JQuery
库。
获取已编译页面的html代码,并检查是否存在对Jquery JS file