doz97171 2016-06-23 12:00
浏览 15

如果选择输入html,则为Javascript值

I have an input html country and a script like this:

checkout.php Input html :

<div class="col-md-6">
         <div class="form-group">
           <label for="country_shipping">Paese<sup>*</sup></label>
              <select class="form-control dark" id="country_ship" name="country_ship" tabindex="-1">

                    <option value="Afganistan">Afghanistan</option>
                    .... with all countries
              </select>
            </div>
</div>

My FIRST script:

<script> 

    $('#country_ship').change(function() {
      if($(this).val() == "Italy" 

        )
      {
         $('#price_ship').val('<?php echo $Italy;?>'); // it work well
         $('data-amount').val('{{ $total * 100 - $price_coupon * 100 + $Italy * 100 }}'); // it doesnt work well
         $('#total_ship').val('<?php echo number_format($total - $price_coupon + $Italy, 2);?>');  // it work well
      }
   });
</script>

My SECOND Script (button stripe):

<script
                                    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
                                    data-key="pk_test_yNuawoy0jUqj1GC14jwcQR5d"
                                    data-amount=""
                                    data-name="dixard"
                                    data-description="Widget"
                                    data-image="https://s3.amazonaws.com/stripe-uploads/acct_14s03fK9wMx3sd9Bmerchant-icon-1416180891533-icona.jpg"
                                    data-locale="auto"
                                    data-currency="eur"

                                    data-id="stripe"

                                    >
</script>

In my FIRST script i'm trying to give a value if user select country Italy, but it doesn't work! I would like attribute a value to "data-mount" with my operation.

maybe I'm wrong here:

$('data-amount').val('{{ $total * 100 - $price_coupon * 100 + $Italy * 100 }}');

my variables like $total, $price_coupon, $italy exist and return the right values. i'm using "{{" because i'm using laravel blade template.

Thank your for your help!

  • 写回答

2条回答 默认 最新

  • dsjklb0205 2016-06-23 12:34
    关注

    $('data-amount') targets tag name.

    if you want to target attribute, use

    $('[data-amount]')
    
    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错