Добрый день,
Нужна помощь в доработке скрипта (формы).
1. Обработка select без перезагрузки;
2. Отправка данных на email.
Строки подписанные, сейчас работает, но с .trigger('submit'); и нужно прикрутить отправка на email.
<html>
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
function submitSelectedVals(){
if(jQuery('#selrow').val() > 0 && jQuery('#selcol').val() > 0){
jQuery('#selrow').closest('form').trigger('submit');
}
}
</script>
</head>
<body>
<?php
require_once 'Classes/PHPExcel.php';
require_once 'Classes/PHPExcel/Worksheet.php';
$excel = PHPExcel_IOFactory::load('costing-example.xls');
foreach($excel ->getWorksheetIterator() as $worksheet) {
$lists[] = $worksheet->toArray();
}
foreach($lists as $list){
echo '<table border="1">';
// Перебор строк
foreach($list as $row){
echo '<tr>';
// Перебор столбцов
foreach($row as $col){
echo '<td>'.$col.'</td>';
}
echo '</tr>';
}
echo '</table>';
}
//---------------------------------------
//http://swblog.ru/articles/programming/sozdaem-otchety-v-excel-na-php.html
require_once ('Classes/PHPExcel/IOFactory.php');
// Открываем файл
//$excel = PHPExcel_IOFactory::load('costing-example.xls');
// Устанавливаем индекс активного листа
$excel->setActiveSheetIndex(0);
// Получаем активный лист
$sheet = $excel->getActiveSheet();
//перебор первой строки
$cols = array();
$row = 1;
$lastColumn = $sheet->getHighestColumn();
$lastColumn++;
for ($column = 'A'; $column != $lastColumn; $column++) {
$val = $sheet->getCell($column.$row)->getValue();
$cols[$val] = $column;
}
//перебор первой колонки
$rows = array();
$column = 'A';
$lastRow = $sheet->getHighestRow();
for ($row = 1; $row <= $lastRow; $row++) {
$val = $sheet->getCell($column.$row)->getValue();
$rows[$val] = $row;
}
//$y = isset($_GET['col'])? (int) $_GET['col'] : 1;
$y = isset($_POST['col'])? (int) $_POST['col'] : array_keys($cols)[1];
//$x = isset($_GET['row'])? (int) $_GET['row'] : 1;
$x = isset($_POST['row'])? (int) $_POST['row'] : array_keys($rows)[1];
echo $y;
echo $x;
$value1 = $sheet->getCell($cols[$y] . $rows[$x])->getValue();
$formatted_number = number_format($value1, 0,',',' ');
?>
<div class="col-sm-12 calculator">
<div class="col-sm-3 calc-form">
<form id="gatesize" action="" method="post">
Высота:
<select id="selrow" name="row" onchange="submitSelectedVals();">
<? foreach($rows as $key => $row): ?>
<option value="<?= $key; ?>"><?= $key; ?></option>
<? endforeach; ?>
</select>
Ширина:
<select id="selcol" name="col" onchange="submitSelectedVals();">
<? foreach($cols as $key => $col): ?>
<option value="<?= $key; ?>"><?= $key; ?></option>
<? endforeach; ?>
</select>
<div class="col-sm-4 calc-additionally" id="calc-additionally" >
<p>Дополнительно:</p>
<p class="calc-addit-install">
<span class="calc-addit-with"><input name="install" type="radio" value="with-install" checked> С установкой</span>
<span class="calc-addit-without"><input name="install" type="radio" value="without-install"> Без установки</span>
</p>
</div>
<input type="button" id="button" onchange="sub();" value="Отправить" />
</form>
<div id="calc-basic" class="col-sm-4 calc-basic" method="post">
<p>Высота: <span class="calc-нeight"><?php echo $x ?></span> мм</p>
<p>Ширина: <span class="calc-width"><?php echo $y ?></span> мм</p>
<p>Сумма: <span class="calc-summa"style="font-size: 18px;"><?php echo $formatted_number ?></span> рублей</p>
</div>
<?php
echo '<pre>';
print_r(array_keys(get_defined_vars()));
//print_r(get_defined_vars());
echo '</pre>';
?>
</body>
</html>