pacnik
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Прошу помочь, пользователь выбирает нужные ему карты, в конце здесь <span id="totalСost"> 0<ins> 0</ins></span> выдается общая сумма заказа. Проблема в том что не могу передать эти данные на send.php Как сформулировать запрос? Пытался переделать span id="totalСost" на input, тогда не работает скрипт. Прошу помочь Код Html <script type="text/javascript" src="images/cardsUse.js"></script> <script type="text/javascript"> var selectedCards = {"500 U" : {"id" : "1", "cost" : "525", "cnt" : "0"},"1000 U" : {"id" : "2", "cost" : "1050", "cnt" : "0"},"2000 U" : {"id" : "3", "cost" : "2100", "cnt" : "0"},"3000 U" : {"id" : "4", "cost" : "3150", "cnt" : "0"},"5000 U" : {"id" : "5", "cost" : "5250", "cnt" : "0"}}; var percent_Io = 0; var percent_Uz = 6.8; </script> <form action="send.php" method="post" name="orderForm" id="orderForm" style="padding:0px;margin:0px;"> <input type="hidden" name="cards" id="cards"> <div class="middle-container"> <div class="center-div"> <div class="cards-container"> <div id="requizBlock"> <div class="card-container"> <span>500</span> <img src="images/buy_webm.jpg" style="cursor:pointer;" origwm="500 ZM" id="origCard_1" onclick="addDelCard("1", "add")"> </div> <div class="card-container"> <span>1000</span> <img src="images/buy_webn.jpg" style="cursor:pointer;" origwm="1000 ZM" id="origCard_2" onclick="addDelCard("2", "add")"> </div> <div class="card-container"> <span>2000</span> <img src="images/buy_webo.jpg" style="cursor:pointer;" origwm="2000 ZM" id="origCard_3" onclick="addDelCard("3", "add")"> </div> <div class="card-container"> <span>3000</span> <img src="images/buy_webp.jpg" style="cursor:pointer;" origwm="3000 ZM" id="origCard_4" onclick="addDelCard("4", "add")"> </div> <div class="card-container"> <span>5000</span> <img src="images/buy_webq.jpg" style="cursor:pointer;" origwm="5000 ZM" id="origCard_5" onclick="addDelCard("5", "add")"> </div> <div class="clear"></div> </div> </div> </div> </div> <div class="bottom-container cards" style="background:#0A79A9;"> <div class="center-div"> <div class="order-list"> <h2>Детали Вашего заказа:<ins>Детали Вашего заказа:</ins></h2> <div style="height:280px;"> <table cellpadding="0" cellspacing="0" border="0" class="order-cards"> <thead> <tr> <td class="item"><span>Карта<ins>Карта</ins></span></td> <td class="num"><span>Кол-во<ins>Кол-во</ins></span></td> <td class="price"><span>Цена<ins>Цена</ins></span></td> <td class="del"></td> </tr> </thead> <tbody class="total-price"> <tr id="cardsTr_1" style="display:none;"> <td class="item">U карта на 500 руб</td> <td class="num"><span class="buttons-container"> <button type="button" class="add" onclick="addDelCard("1", "add");"></button> <button type="button" class="remove" onclick="addDelCard("1", "del");"></button> </span> <input type="text" value="1" style="width:20px;" id="cardsCount_1"></td> <td class="price" id="cardsPrice_1"><span id="cardVal">руб</span> 525</td> <td class="del"><a class="delete-button" onclick="addDelCard("1", "del");"></a></td> </tr> <tr id="cardsTr_2" style="display:none;"> <td class="item">U карта на 1000 руб</td> <td class="num"><span class="buttons-container"> <button type="button" class="add" onclick="addDelCard("2", "add");"></button> <button type="button" class="remove" onclick="addDelCard("2", "del");"></button> </span> <input type="text" value="1" style="width:20px;" id="cardsCount_2"></td> <td class="price" id="cardsPrice_2"><span id="cardVal">руб</span> 1050</td> <td class="del"><a class="delete-button" onclick="addDelCard("2", "del");"></a></td> </tr> <tr id="cardsTr_3" style="display:none;"> <td class="item">U карта на 2000 руб</td> <td class="num"><span class="buttons-container"> <button type="button" class="add" onclick="addDelCard("3", "add");"></button> <button type="button" class="remove" onclick="addDelCard("3", "del");"></button> </span> <input type="text" value="1" style="width:20px;" id="cardsCount_3"></td> <td class="price" id="cardsPrice_3"><span id="cardVal">руб</span> 2100</td> <td class="del"><a class="delete-button" onclick="addDelCard("3", "del");"></a></td> </tr> <tr id="cardsTr_4" style="display:none;"> <td class="item">U карта на 3000 руб</td> <td class="num"><span class="buttons-container"> <button type="button" class="add" onclick="addDelCard("4", "add");"></button> <button type="button" class="remove" onclick="addDelCard("4", "del");"></button> </span> <input type="text" value="1" style="width:20px;" id="cardsCount_4"></td> <td class="price" id="cardsPrice_4"><span id="cardVal">руб</span> 3150</td> <td class="del"><a class="delete-button" onclick="addDelCard("4", "del");"></a></td> </tr> <tr id="cardsTr_5" style="display:none;"> <td class="item"> U карта на 5000 руб</td> <td class="num"><span class="buttons-container"> <button type="button" class="add" onclick="addDelCard("5", "add");"></button> <button type="button" class="remove" onclick="addDelCard("5", "del");"></button> </span> <input type="text" value="1" style="width:20px;" id="cardsCount_5"></td> <td class="price" id="cardsPrice_5"><span id="cardVal">руб</span> 5250</td> <td class="del"><a class="delete-button" onclick="addDelCard("5", "del");"></a></td> </tr> <tr> <td class="item"> </td> <td class="total"><span>Общая сумма:<ins>Общая сумма:</ins></span></td> <td class="total-price"> <span id="totalСost"> 0<ins> 0</ins></span> </td> <td class="del"></td> </tr> </tbody> </table> </div> </div> и код из cardsUse.js var fieldsFilled = true;//Поля для оформления карт заполнены var fieldsFilledError = '';//Ошибка заполнения полей var sposob = ''; var totalCost = 0; var loginStat = false; var emailStat = false; var keystring = 0; var good = true; function changeSposob(sp){ sposob = sp; addDelCard('', ''); } $(document).ready(function(){ changeSposob('sw') }); function addDelCard(id, func){//++ if (sposob == '') sposob == 'sw'; if (func == 'add' || func == 'del'){ var wm = $('#origCard_'+id).attr('origWm'); //var cost = $('#origCard_'+id).attr('origCost'); if (func == 'add') selectedCards[wm]['cnt']++; if ((func == 'del') && (selectedCards[wm]['cnt'] > 0)) selectedCards[wm]['cnt']--; } var cnt = 0; var cost = 0; var koef = 1; totalCost = 0; if (sposob == 'lp') koef = 1*(1+percent_U/100); var cards = ''; var arr = Array(); for (var a in selectedCards){ if (selectedCards[a]['cnt'] > 0){ cards += selectedCards[a]['cnt']+'x'+a+','; cost = Math.round(selectedCards[a]['cnt']*selectedCards[a]['cost']*100*koef)/100; $('#cardsCount_'+selectedCards[a]['id']).val(selectedCards[a]['cnt']); /*if (sposob == 'mg'){ $('#cardsPrice_'+selectedCards[a]['id']).html('€ '+cost); }else{ $('#cardsPrice_'+selectedCards[a]['id']).html(' '+cost); }*/ $('#cardsPrice_'+selectedCards[a]['id']).html(' '+cost); $('#cardsTr_'+selectedCards[a]['id']).show(); arr[cnt] = selectedCards[a]['id']; totalCost += cost; cnt++; }else{ $('#cardsTr_'+selectedCards[a]['id']).hide(); } } cards = cards.substr(0, cards.length-1); $('#cards').val(cards); if (totalCost > 1100000 && (sposob == 'wu' || sposob == 'mg')){ $('#totalMax').show(); }else{ $('#totalMax').hide(); } totalCost = Math.round(totalCost*100)/100; $('#totalcost').html(' '+totalCost+'<ins> '+totalCost+'</ins>'); for (var a in arr){ if (arr[a] > 0){ if (a%2 == 0){ document.getElementById('cardsTr_'+arr[a]).className = 'odd'; }else{ document.getElementById('cardsTr_'+arr[a]).className = ''; } } } } |