我想从选择框中拆分值,因为我必须向客户显示总价并向管理员发送邮件。如果我不使用拆分值,那么我无法将选择选项标签发送给管理员进行订单处理。我尽了最大的努力,但我失败了.....我再次问这个问题......请帮助我解决这个问题
<div id="target">
<table cellpadding="10">
<tr>
<td colspan="2">
<div>
<label>Choose Currency</label>
<select id="currency" class="shopEssaySelect" name="txtCurrency" required>
<option selected disabled value="">Choose ...</option>
<?php echo ShowCurrencies(); ?>
</select>
</div>
<div>
<label>Type of Paper</label>
<select id="category" class="shopEssaySelect" name="txtPaperType" required>
<option selected disabled value="">Choose ...</option>
<?php echo ShowCategory(); ?>
</select>
</div>
<div>
<label>Academic Level</label>
<select id="type" class="shopEssaySelect" name="txtAcademicLevel" required>
<option selected disabled value="">Choose ...</option>
<?php echo ShowType(); ?>
</select>
</div>
<div>
<label>Deadline</label>
<select id="deadline" class="shopEssaySelect" name="txtDeadline" required>
<option selected disabled value="">Choose ...</option>
<?php echo ShowDeadline(); ?>
</select>
</div>
<div>
<label>Service Type</label>
<select id="servicetype" class="shopEssaySelect" name="txtServiceType" required>
<option selected disabled value="">Choose ...</option>
<?php echo ShowServiceType(); ?>
</select>
</div>
<div>
<label>Line Spacing</label>
<select id="linespacing" class="shopEssaySelect" name="txtLineSpacing" required>
<option selected disabled value="">Choose ...</option>
<?php echo ShowLineSpacing(); ?>
</select>
</div>
<div>
<label>Paper Format</label>
<div class="paper-format">
<input type="radio" name="txtPaperFormat" value="MLA">MLA
<input type="radio" name="txtPaperFormat" value="APA">APA
<input type="radio" name="txtPaperFormat" value="Chicago">Chicago / Turabian
<input type="radio" name="txtPaperFormat" value="Harvard">Harvard
<input type="radio" name="txtPaperFormat" value="Other">Other
</div>
</td>
</tr>
</table>
</div><!-- end of target -->
// jquery code is here
function updateTotal(){
currency = $("#currency").val();
currency_array = currency.split("/");
currency_percentage = currency_array[0];
currency_symbol = currency_array[1];
$("#curr-symbol").text(currency_symbol);
// from here split does not work
paper_values = $("#category").val();
paper_array = paper_values.split("/");
paper = paper_array[0];
type_values = $("#type").val();
type_array = type_values.split("/");
type_percentage = type_array[0];
deadline_values = $("#deadline").val();
deadline_array = deadline_values.split("/");
deadline_percentage = deadline_array[0];
service_values = $("#servicetype").val();
service_array = service_values.split("/");
service_percentage = service_array[0];
// but from here split works
spacing = $("#linespacing").val();
spacing_array = spacing.split("/");
spacing_percentage = spacing_array[0];
spacing_words = spacing_array[1];
type = (paper * type_percentage) / 100;
deadline = (paper * deadline_percentage) / 100;
servicetype = (paper * service_percentage) / 100;
linespacing = (paper * spacing_percentage) / 100;
currency = (paper * currency_percentage);
words = Number($("#numberOfPages").val());
counted_words = words * spacing_words;
$("#totalwords").text(counted_words);
total_amount = (paper + type + deadline + servicetype + linespacing + currency) * words;
if (!isNaN(total_amount)){
total_amount = Math.round((paper + type + deadline + servicetype + linespacing + currency) * words);
}
else {
total_amount ="0";
}
$("#total").text(total_amount);
}
$(".shopEssaySelect").change(function(){
updateTotal();
})
$("#numberOfPages").on("input", function(event) {
updateTotal();
})
// php code is here function ShowCategory() { $sql = "SELECT pd_id, c.cat_id,base_price, cat_name, pd_name FROM tbl_bbproduct p, tbl_bbcategory c WHERE p.cat_id = c.cat_id ORDER BY cat_name"; $result = mysql_query($sql); $category_name = array(); while ($row = mysql_fetch_assoc($result)) { $category_name[$row['cat_name']][] = $row; } foreach ($category_name as $key => $values) { echo ''; foreach ($values as $row) { echo ''.$row['pd_name'].''; } echo ''; } } function ShowType() { $sql = "SELECT * FROM tbl_academic_level"; $res = mysql_query($sql); while($row = mysql_fetch_array($res)) { echo '' . $row['level_name'] . ''; } return ; } function ShowDeadline() { $sql = "SELECT * FROM tbl_deadline"; $res = mysql_query($sql); while($row = mysql_fetch_array($res)) { echo '' . $row['deadline_name'] . ''; } return ; } function ShowServiceType() { $sql = "SELECT * FROM tbl_service_type"; $res = mysql_query($sql); while($row = mysql_fetch_array($res)) { echo '' . $row['service_name'] . ''; } return ; } function ShowLineSpacing() { $sql = "SELECT * FROM tbl_line_spacing"; $res = mysql_query($sql); while($row = mysql_fetch_array($res)) { echo '' . $row['spacing_name'] . ''; } return ; } function ShowCurrencies() { $sql = "SELECT * FROM tbl_currencies"; $res = mysql_query($sql); while($row = mysql_fetch_array($res)) { echo '' . $row['currency_name'] . ''; } return ; }