我有一个预填列表,具体取决于网站内的点击次数。变量值填充有单击元素的数据名称。单击在后台工作的提交按钮后,是否有一种通过电子邮件发送变量值的方法,例如无法打开电子邮件客户端。
var operatorPrice = "";
var emergencyStop = "";
$(".estop").click(function() {
emergencyStop = $(this).attr("data-name");
document.getElementById("station").innerHTML = emergencyStop;
operatorPrice = $(this).attr("name");
document.getElementById("station-price").innerHTML = operatorPrice;
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<li>
<span id="station"></span> <span id="station-price" class="qty price">
</span>
</li>
答案 0 :(得分:0)
如果我是对的,您是否需要将变量添加到电子邮件客户端的功能?
我做过类似的事情,而且我是初学者,这是我的做法。
function errorModal(dataObject) {
// Get the parent element to append a button and h3
const divDOM = document.querySelector('#apnd');
// Create h3 message
const h3DOM = document.createElement('h3');
h3DOM.classList.add('text-white', 'text-center', 'py-3');
h3DOM.textContent = 'An error occured :(';
// Create the a tag
let aDOM = document.createElement('a');
// Add class to the a tag
aDOM.classList.add('btn', 'btn-lg', 'btn-warning');
aDOM.textContent = 'SEND AN EMAIL!';
// Email body and add a attribute href
aDOM.href = 'mailto:hello@example.com?subject=From%20a%20Website&body=Website:%20' +dataObject.websiteForma+ '%0D%0A%20Name:%20' +dataObject.nameForma+
'%0D%0A%20Phone:%20' +dataObject.phoneForma+ '%0D%0A%20Goals:%20' +dataObject.whatAreYourGoals+ '%0D%0A%20Where%20do%20you%20advertise:%20' +dataObject.whereDoYouAdvertise+
'%0D%0A%20Leads%20or%20Sales:%20' +dataObject.doYouWantLeadsOrSales+ '%0D%0A%20PPC%20spend%20' +dataObject.PpcSpend+ "%0D%0A%0D%0A%20Don't%20worry%20just%20hit%20send.%20";
// Append h3 tag to the parent
divDOM.appendChild(h3DOM);
// Append a tag to the parent
divDOM.appendChild(aDOM);
}
%20-用于空格。 %0D%0A-用于换行。
答案 1 :(得分:0)
想通了我是怎么做到的。 单击“提交”后,使用Json将变量值转换为PHP。
(kernel_size[0], kernel_size[1], num_output_channels)
然后在jsonTest.php中
$.ajax({
url:"jsonTest.php",
method: "post",
data: { operatorOne: JSON.stringify( emergencyStop ) },
success: function(res){
console.log(res);
}
})
});
尽管其中包含一些反斜杠,但现在成功地收到了带有可变值的电子邮件。