[英]submit form on click of a link and send to multiple email ids
I have formatted my form using uniform jquery plugin. 我使用统一的jquery插件格式化了我的表单。 Also for submitting the form i am using a link as i have added some effect to it and if I use input type submit for this it will get formatted with uniform . 另外提交表单我使用链接,因为我已经添加了一些效果,如果我使用输入类型提交为此它将格式化为统一。
<form>
<ul>
<li><label>Your Name:</label><input type="text" name="name" size="40"/></li>
<li><label>Your Email:</label><input type="email" name="email" size="40"/></li>
<li>
<label>Gender:</label>
<select name="gender">
<option>Male</option>
<option>Female</option>
</select>
</li>
<li><label>Subject:</label><input type="text" name="subject" size="40"/></li>
<li><label>Write your letter here:</label><textarea name="message" cols="60" rows="15"></textarea></li>
OR ELSE<br/><br/>
<li>
<label>Upload your letter:</label>
<input type="file" />
</li>
<li>
<a id="mylink" class="button" href="#">
<img src="button.png" alt="" />Send</a>
</li>
</ul>
</form>
Now i want to submit this form using the link and also want to email it to two email ids simultaneously. 现在我想使用链接提交此表单,并希望同时通过电子邮件将其发送给两个电子邮件ID。 What javascript code can i use. 我可以使用哪些JavaScript代码。 I am using the following code to submit the form and then in send.php I am sending the mail. 我使用以下代码提交表单,然后在send.php我发送邮件。
a.onclick = function() {
$(this).parents('form:first').submit();
send.php;
return false;
}
Is it possible to call send.php like this? 可以像这样调用send.php吗?
Do you mean: 你的意思是:
If you have action="send.php" in your form, then 如果你的表单中有action =“send.php” ,那么
$(document).ready(function() {
$("#mylink").click(function(e) {
e.preventDefault();
$(this).closest('form').submit();
});
});
Or, you can set action for the form and submit, like 或者,您可以为表单设置操作并提交,例如
$(document).ready(function() {
$("#mylink").click(function(e) {
e.preventDefault();
var myFrm = $(this).closest('form');
myFrm.get(0).setAttribute('action', 'send.php');
myFrm.submit();
});
});
OR, using ajax 或者,使用ajax
$(document).ready(function() {
$("#mylink").click(function(e) {
e.preventDefault();
$.ajax({
type: "POST",
url: "send.php",
data: {your data to post here},
succes: function(resp) {
//your response here
}
});
});
});
Is it possible to call send.php like this? 可以像这样调用send.php吗?
Like this ? 喜欢这个 ? No, you need to use ajax
request: 不,您需要使用ajax
请求:
$.ajax({
url :"send.php"
});
Extra tip: change: 额外提示:更改:
$(this).parents('form:first').submit();
To: 至:
$(this).closest('form').submit();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.