2016-10-16 3 views
1

HTMLとPHPを組み合わせ:すべてのdivの下にjqueryの - PHPは変数と出力結果

<?php $a = 1380; ?> 
    <script> 
<?php $b = document.write(month); ?> 
    </script> 
<div id="firstshow"> 

    <div id="test1"> 
     <div class="col-xs-5 text-right"> 
     <b><?php echo $a/$b; ?> &euro;/month</b><!-- the result I wish to divide $a from $b --> 
     </div> 
    </div> 

    <div class="dropdown"> 
     <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"><b class="pull-left">36</b>per month 
     <i class="fa fa-chevron-down pull-right" aria-hidden="true"></i></button> 
     <ul class="dropdown-menu"> 
      <li><a href="#">12</a></li> 
      <li><a href="#">24</a></li> 
      <li><a href="#">36</a></li> 
     </ul> 
    </div> 

</div> 

は、この(下記)のjQueryのスクリプトです。

私はjqueryのの結果として変数月にPHPで動的変数$ aを組み合わせて、2にそれらを分割しようとしています

$("#firstshow .dropdown-menu li a").click(function(){ 
    var month = $('#firstshow button b').text($(this).text()); 
}); 

のjQuery。

+1

を。 ?> '? – Dekel

+0

この場合、結果は36です。 –

+0

[クライアント側とサーバー側のプログラミングの違いは何ですか?](http://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server - –

答えて

0

私は解決策を見つけました。 ?のdivの最後に、私は、スクリプト

<script type="text/javascript"> 
    jQuery(document).ready(function($){ 
     $("#firstshow .dropdown-menu li a").click(function(){ 

     $('#test1 .col-xs-5 span').text(<?php echo $a; ?>/($(this).text())); 

    }); 
     }); 
</script> 

とHTMLの変更、追加:あなたはこの行 `

<div id="test1"> 
<div class="col-xs-7"> 
    <span>1.459&euro;</span> <b>1.380 &euro;</b> 
</div> 
<div class="col-xs-5 text-right"> 
    <b><span>36</span> &euro;/month</b>  
</div> 
</div> 
関連する問題