Обновить общую стоимость на основе выбора радиовхода - PullRequest
0 голосов
/ 20 февраля 2012

У меня есть таблица с 8 кнопками радиовхода, и я хочу обновить общую стоимость в зависимости от выбора радиовхода пользователя. Как мне добиться этого с помощью jQuery?

<table>
  <tr>
    <td></td>
    <form name="m" action="" method="post">
      <th> <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(false);" type="radio" value="P2"/>
        <label for="purchaseChoice">£5</span> </label>
        <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(true);" type="radio" value="P1"/>
        <label for="purchaseChoice">£10</label>
      </th>
      <th class=""> <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(true);" type="radio" value="S111"/>
        <label for="purchaseChoice">£20</label>
        <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(false);" type="radio" value="S112"/>
        <label for="purchaseChoice">£30</label>
      </th>
      <th class=""> <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(true);" type="radio" value="S131"/>
        <label for="purchaseChoice">£40</label>
        <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(false);" type="radio" value="S132"/>
        <label for="purchaseChoice">£50</label>
      </th>
      <th class="highlight"> <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(true);" type="radio" value="S121"/>
        <label for="purchaseChoice">£60</label>
        <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(false);" type="radio" value="S122"/>
        <label for="purchaseChoice">£70</label>
      </th>
    </form>
  </tr>
  <tr>
    <th class="total">TOTAL YOU PAY</th>
    <th> 
     <div class="Priceband"></div>
    </th>
  </tr>
</table>

Спасибо

Ответы [ 2 ]

0 голосов
/ 20 февраля 2012

если я правильно понимаю ваши требования, то вы просто хотите обновить цену с измененным выбором.

пожалуйста, найдите код ниже. может быть полезным для вас.

<table>
  <tr>
    <td></td>
    <form name="m" action="" method="post">
      <th> <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(this);" type="radio" value="P2"/>
        <label for="purchaseChoice">£5</span> </label>
        <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(this);" type="radio" value="P1"/>
        <label for="purchaseChoice">£10</label>
      </th>
      <th class=""> <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(this);" type="radio" value="S111"/>
        <label for="purchaseChoice">£20</label>
        <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(this);" type="radio" value="S112"/>
        <label for="purchaseChoice">£30</label>
      </th>
      <th class=""> <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(this);" type="radio" value="S131"/>
        <label for="purchaseChoice">£40</label>
        <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(this);" type="radio" value="S132"/>
        <label for="purchaseChoice">£50</label>
      </th>
      <th class="highlight"> <input id="test" name="purchaseChoice" class="radio" onclick="return togglePrices(this);" type="radio" value="S121"/>
        <label for="purchaseChoice">£60</label>
        <input id="test" name="purchaseChoice" class="radio" onclick="togglePrices(this);" type="radio" value="S122"/>
        <label for="purchaseChoice">£70</label>
      </th>
    </form>
  </tr>
  <tr>
    <th class="total">TOTAL YOU PAY</th>
    <th> 
     <div class="Priceband"></div>
    </th>
  </tr>
</table>
<script language="javascript" type="text/javascript" >

    function togglePrices(e) {
        var price = $(e).val();
        $(".Priceband").html(price);
    }

</script>
0 голосов
/ 20 февраля 2012

Вы должны использовать onselectionchanged событие, чтобы вызвать соответствующую функцию, которая обновит общую сумму.Вы можете посмотреть по ссылке ниже http://www.phpbuilder.com/board/archive/index.php/t-10307334.html

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...