$("second_select").change(function(){
var first = document.getElementById('first_select');
if (first)
{
if (first.selectedIndex != null)
{
//////
}else{
alert('Сначала выберите первый селект');
}
}
});
$buffer = file_get_contents($url);
$finfo = new finfo(FILEINFO_MIME_TYPE);
return $finfo->buffer($buffer);
<?
function menu()
{
$sm_read = file("templates/menu.html");
$sm_read = implode("",$sm_read);
return $sm_read;
}
?>
array(2) { [0]=> string(0) "" [1]=> string(0) "" }
<?php
$url = explode('/',strtolower(substr($_SERVER['REQUEST_URI'], 1)));
switch($url[0]) {
case '': {
include("moduls/main.php");//?????????? ??????
$txt = menu();
break;
}
?>
if($page == "index"){
include("moduls/menu.php");
$txt = menu();
}
if($page == "index"){
include("moduls/menu.php");
$txt = menu();
}
<form id="buy" method="post">
<div class="form-group">
<label for="name">Ваше имя</label>
<input type="name" name="name" class="form-control" id="name" placeholder="Ваше имя" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" name="email" class="form-control" id="email" placeholder="Email" required>
</div>
<div class="form-group">
<label for="dannie">Данные</label>
<input type="text" name="dannie" class="form-control" id="dannie" placeholder="Введите данные от аккаунта" required>
</div>
<div class="form-group">
<label for="product">Выбранный товар</label>
<input type="text" name="product" class="form-control" id="product" readonly>
</div>
<div class="form-group" id="kolvo" style="display: none;">
<?php
$id = (int)$_GET['id'];
$result_index2 = mysql_query("SELECT * FROM shop WHERE idtovar = {$id}");
echo "<label id='kolvo'>Кол-во товара</label>";
echo '<select name="kolvo" id="kolvo_price">';
echo '<option value="0" selected disabled>Выбрать кол-во</option>';
while ($result = mysql_fetch_array($result_index2)){
echo '<option value='.$result['price'].'>'.$result['kolvo'].' $</option>';
}
echo '</select>';
?>
</div>
<script type='text/javascript'>
document.getElementById('kolvo_price').addEventListener('change', function(){
document.getElementById('pricesviborinput').value = this.value;
});
</script>
<div class="form-group" id="pricesvibor" style="display: none;">
<label for="price">Цена</label>
<input type="text" name="price" class="form-control" id="pricesviborinput" readonly>
</div>
<div class="form-group" id="pricebezvibor" style="display: none;">
<label for="price">Цена</label>
<input type="text" name="price" class="form-control" id="price" readonly>
</div>
<div class="form-group" style="display: none;">
<label for="photo">Фото</label>
<input type="text" name="photo" class="form-control" id="photo" readonly>
</div>
<div class="form-group">
<label for="promo">Промокод (если есть)</label>
<input type="text" name="promo" class="form-control" id="promo">
</div>
<button type="submit" class="btn btn-primary">Купить</button>
</form>
<script type="text/javascript">
var price_check;
$('.buy').on('click',function(){
my_id = $(this).attr('data-id');
$.get('/tovar.php?id=' + my_id, function(data){
price_check = data["price"];
$('#price').val(data["price"]);
$('#product').val(data["name"]);
$('#photo').val(data["photo"]);
$('#vibor').val(data["vibor"]);
$('#cart').modal();
if(data["vibor"] == 0){
document.getElementById('kolvo').style.display = "none";
document.getElementById('pricebezvibor').style.display = "block";
document.getElementById('pricesvibor').style.display = "none";
document.getElementById('pricesviborinput').disabled = "disabled";
}
if(data["vibor"] == 1){
document.getElementById('kolvo').style.display = "block";
document.getElementById('pricebezvibor').style.display = "none";
document.getElementById('pricesvibor').style.display = "block";
document.getElementById('price').disabled = "disabled";
}
});
});
$("#buy").submit(function() {
if(document.getElementById('price').value != price_check){
$('#price').val(price_check);
}
});
</script>
Или в ВК: https://vk.com/makspaver