我有一个html网站,并使用手册下载选项和表格。每个项目都有很多表格。我只需要一个下载宣传册的表格取决于项目的隐藏输入值。
jQuery(".form-js-pop-vedam").submit(function () {
var thisform = jQuery(this);
jQuery('.required-error',thisform).remove();
var pmail = jQuery("#pmail").val();
var pphone = jQuery("#pphone").val();
var psubject = jQuery("#psubject").val();
var data = {'pmail':pmail,'pphone':pphone,'psubject':psubject}
if (pmail == "") {
jQuery("#pmail").after('<span class="form-description required-error">Required field.</span>');
}else {
jQuery("#pmail").parent().find('.required-error').remove();
}
if (pphone == "") {
jQuery("#pphone").after('<span class="form-description required-error">Required field.</span>');
}else {
jQuery("#pphone").parent().find('.required-error').remove();
}
if ( pmail != "" && pphone != "" ) {
jQuery.post("contact_us_pop-vedam.php",data,function (result) {
if (result == "done") {
thisform.prepend("<div class='alert-message success-amairo'><i class='icon-ok'></i><p><span>Vedam brochure was sent to your mail. Thank you!</span></p></div>");
jQuery("#pmail").val("");
jQuery("#pphone").val("");
}
});
}
return false;
});
<form class="form-style form-js-pop-vedam" action="contact_us_pop-vedam.php" method=post>
<input type="hidden" name="psubject" id="psubject" value="Brochure Download from Vedam Page">
<div class="col-md-6" ><input type=email class=required-item id=pmail name=pmail value="" aria-required=true placeholder="Your Email*"></div>
<div class="col-md-6 " ><input class=required-item aria-required=true id=pphone name=pphone value="" placeholder="Your Phone*"></div>
<div class="col-md-6 " ><input name=submit type=submit value="Download Now >" class="submit_buttom buttonColor-side" id="Brochure_Download"></div>
</form>
<!-- language: lang-php -->
<?php
function clean_text($text='') {
$text = trim($text);
$text = strip_tags($text);
$text = addslashes($text);
$text = htmlspecialchars($text);
return $text;
}
if (!$_POST) {
die();
}else {
if (empty($_POST["pphone"]) && empty($_POST["pmail"]) ) {
echo "all_empty";
}else if (empty($_POST["pmail"])) {
echo "empty_mail";
}else if (empty($_POST["pphone"])) {
echo "empty_phone";
}else {
// edit this only :)
$your_email = "me@myweb.com";
$pmail = clean_text($_POST["pmail"]);
$pphone = clean_text($_POST["pphone"]);
$psubject = clean_text($_POST["psubject"]);
$subject = "$psubject";
$headers = "From: leads@website.in" . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8'. "\r\n";
$msg = "New Brochure Download \n<br />";
$msg .= "Email : \t $pmail \r\n<br />";
$msg .= "Phone : \t $pphone \r\n<br />";
echo "done";
$done = @mail($your_email, $subject, $msg, $headers);
}if($done)
{
if(($pmail)) {
$headerRep = "From: Website <info@website.in>";
$subjectRep = "Greetings from website!";
$messageRep = "Hi, \n\r
Thanks for showing interest in our property \n\r";
$messageRep .="You can download the brochure here http://www.example.in/pdf/brochure.pdf";
@mail($pmail, $subjectRep, $messageRep, $headerRep);
}
}
}
?>
<!-- end snippet -->
答案 0 :(得分:0)
让我们一般性地谈谈单词(隐藏)..我们有2个案例
第一种情况: type="hidden"
的输入您可以使用这样的选择器
在css中
input[type="hidden"]{}
和js
$('input[type="hidden"]') // you can use .val() or .attr() depending on data you want from it
检查表单是否输入隐藏类型
if($('form').find('input[type="hidden"]').length > 0){ // in submit event use $(this).find instead if $('form').find
// yes this is input with type hidden here
}else{
// no input with type hidden here
}
当你说(取决于隐藏的输入值)时,你可以用
检查if($('form').find('input[type="hidden"]').val() == 'something'){ // in submit event use $(this).find instead if $('form').find
// type input hidden value = something
}else{
// type input hidden value not = something
}
第二种情况::隐藏和:可见,关于元素的信息是否可见,我认为你不需要它