聪明的模板在进入js验证后变得空白

时间:2013-05-29 08:41:45

标签: smarty prestashop

pinterest js

<script type="text/javascript">
(function(d){
  var f = d.getElementsByTagName('SCRIPT')[0], p = d.createElement('SCRIPT');
  p.type = 'text/javascript';
  p.async = true;
  p.src = '//assets.pinterest.com/js/pinit.js';
  f.parentNode.insertBefore(p, f);
}(document));
</script>

css文件

<link rel='stylesheet' href='css/fab-sales.css' media='all' type='text/css' />
<link rel='stylesheet' href='css/basic.css' media='all' type='text/css' />

{if isset($products)}
    <!-- Products list -->
    <ul id="product_list" class="clear">
    {foreach from=$products item=product name=products}
    {assign var=foo value=$product.link}
        <li class="ajax_block_product {if $smarty.foreach.products.first}first_item{elseif $smarty.foreach.products.last}last_item{/if} {if $smarty.foreach.products.index % 2}alternate_item{else}item{/if} clearfix">
            <div class="left_block">
                {if isset($comparator_max_item) && $comparator_max_item}
                    <p class="compare">
                        <input type="checkbox" class="comparator" id="comparator_item_{$product.id_product}" value="comparator_item_{$product.id_product}" {if isset($compareProducts) && in_array($product.id_product, $compareProducts)}checked="checked"{/if} /> 
                        <label for="comparator_item_{$product.id_product}">{l s='Select to compare'}</label>
                    </p>
                {/if}
            </div>



<div class="center_block">
  <div align="center" id="prodList">
  <div class="product">
  <div class="prodImgBlock filler" style="cursor:pointer"><a href="{$foo|escape:'htmlall':'UTF-8'}" class="product_img_link" title="{$product.name|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} />{if isset($product.new) && $product.new == 1}<span class="new">{l s='New'}</span>{/if}
                </a></div>
                <div class="newSocialCt">
      <div class="newSocialToolBar"> <span style="left: 10px;" class="newSocialTool faveIt"> <span style="position: relative;top: 4px;display: none;" class="loader"> <img src="img/tmp/ajax-loader-white.gif"> </span></span> <span class="loaderCt newSocialTool"></span> <span class="newSocialTool pinItTool" style="float:left; margin-left:-10px; margin-right:5px;"> <a href="//pinterest.com/pin/create/button/?url=http%3A%2F%2Ffab.com%2Fsale%2F21581%2Fproduct%2F147914%2F&media=http://www.bluehorse.in/Administrator/images/Profile/abhishek.jpg&description=Pin%20it%20on%20Pinterest" data-pin-do="buttonPin" data-pin-config="beside"><img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" /></a> </span> <span class="newSocialTool" style="float:left; width:85px; margin-left:15px;">
        <div id='basic-modal'> <a href='#' class='basic'><img alt="Share" src="img/tmp/tellafriend.png" border="0" /></a> </div>
        </span> <span class="newSocialTool" style="float:none; margin-right:20px;">
      <div class="fb-like" data-href="$foo" data-send="false" data-layout="button_count" data-width="450" data-show-faces="true"></div>
        </span> </div>
    </div> </div>
</div>

<div class="productCt">
      <div class="productDet" id="0"><h4><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'|truncate:35:'...'}</a></h4>
                <p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}" >{$product.description_short|strip_tags:'UTF-8'|truncate:130:'...'}</a></p>
            </div>
    </div></div>

<div id="push" class="clear"></div>

<div id="basic-modal-content">
  <div id="tellFriendBox">
    <div class="popUpHd">
      <h2>Tell A Friend!</h2>
    </div>
    <div class="error" id="tf"></div>
    <form class="" id="" method="post" action="" enctype="multipart/form-data">
      <div class="eachRow">
        <div>Your Name
          <label style="color:#FF0000">*</label>
          :</div>
        <div class='field'>
          <input type='text' id="name" class="required email" name="name"  size='33'/>
        </div>
      </div>
      <div class="eachRow">
        <div>Friends Email Address
          <label style="color:#FF0000">*</label>
          :</div>
        <div class='field'>
          <input type='text' id="email_id" class="required email" name="email"  size='33'/>
        </div>
      </div>
      <div class="eachRow">
        <div>Matter:</div>
        <div class='field'>
          <textarea  rows='4' cols='25' id="matter" class="required" name="matter" ></textarea>
        </div>
      </div>
      <div class="eachRow">
        <div class='field'>
          <input class="button" type='submit' name="tellafriend" onclick="return TellFriend(); "  value="Send Mail"/>
        </div>
      </div>
    </form>
  </div>
</div>
<div style='display:none'> <img src='img/tmp/x.png' alt='' /> </div>     

***将以下javascript代码用于验证后,智能模板变为空白

<script type="text/javascript">
function TellFriend()
 {
  var em = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; 
  if(document.getElementById("name").value == "")
    {
      document.getElementById("tf").innerHTML=  "* Marks Fields are Mandatory ";
      document.getElementById("name").focus();
      return false;
    }
 if(document.getElementById("email_id").value == "")
    {
      document.getElementById("tf").innerHTML=  "* Marks Fields are Mandatory ";
      document.getElementById("email_id").focus();
      return false;
    }
    if (document.getElementById("email_id").value.search(em) == -1) 
    {
          document.getElementById("tf").innerHTML=  "Invalid Email "+"</span>";
          document.getElementById("email_id").focus();
          return false;
     }

 }
</script>

需要帮助..并且在将$ foo作为URL放入pinterest..pinterest计数按钮消失后...

2 个答案:

答案 0 :(得分:0)

您应该将javascript包含在{literal} {/ literal}标记

答案 1 :(得分:0)