下载宣传册取决于隐藏字段的值

Download brochure depends on the hidden field value

本文关键字:字段 隐藏 宣传册 取决于 下载      更新时间:2023-09-26

我有一个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>
 
<!--语言:lang-php-><?php函数clean_text($text="){$text=修剪($text);$text=strip_tag($text);$text=加斜杠($text);$text=htmlspecialchar($text);return$text;}if(!$_POST){die();}其他{if(空($_POST["pphone"])&amp;空($_POST["pmail"]){echo"all_empty";}否则if(空($_POST["pmail"]){echo"empty_mail";}else if(空($_POST["pphone"])){echo"empty_phone";}其他{//仅编辑此:)$your_email="me@myweb.com";$pmail=clean_text($_POST["pmail"]);$pphone=clean_text($_POST["pphone"]);$psobject=clean_text($_POST["psobject"]);$subject="$psobject";$headers="发件人:leads@website.in"."''r''n";$headers.='内容类型:text/html;charset=UTF-8'。"''r''n";$msg="下载新宣传册''n<br/>";$msg.="电子邮件:''t$pmail''r''n<br/>";$msg.="电话:''t$pphone''r''n<br/>";echo"完成";$done=@mail($your_email,$subject,$msg,$headers);}if($done){if(($pmail)){$headerRep="发件人:网站<info@website.in>";$subjectRep="来自网站的问候!";$messageRep="嗨,''n''r感谢您对我们的房产感兴趣''n''r";$messageRep="你可以在这里下载小册子http://www.example.in/pdf/brochure.pdf";@邮件($pmail,$subjectRep,$messageRep,$SeaderRep);}}}><!--结束代码段-->

让我们大致谈谈单词(隐藏)。。我们有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
    }

第二种情况::隐藏和:可见,这是关于元素是否可见的,我认为您在这里不需要它