Не получается отправить get запрос. Надо выбрать один из тре ценноков или ввести свою цену и отправить это методом get, пока что просто в адресную сртоку.
<form action="" method="get">
<fieldset>
<input type="button" name="price" value="500р">
<input type="button" name="price" value="1000р">
<input type="button" name="price" value="5000р">
<input type="text" name="other_price" placeholder="Своя цена">
<input type="submit" name="price_btn">
</fieldset>
</form>
Ввести пятаюсь так
<?php
$_GET['price'];
?>
В чем проблема?
Для автоматической отсылки формы по нажатию кнопки:
<input type="submit" ...
вместо
<input type="button" ...
Имейте в виду, что если будет нажата последняя кнопка, значения с ключом 'price' в запросе не будет.
Или так - с радио-кнопками вместо обычных кнопок:
// this script is here only to demonstrate submitted form data
$("form").submit(function(e) {
console.log($(this).serialize());
return false;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="" method="get">
<fieldset>
<label><input type="radio" name="price" value="500р">500р</label><br/>
<label><input type="radio" name="price" value="1000р">1000р</label><br/>
<label><input type="radio" name="price" value="5000р">5000р</label><br/>
<label><input type="radio" name="price" value="custom">Своя цена</label><br/>
<input type="text" name="custom_price" placeholder="Своя цена">
<input type="submit" name="price_btn">
</fieldset>
</form>
Две формы. В одной человек может выбрать цену, во второй ввести свое значение.
<h3>По нажатию выбранной цены, просто две формы</h3>
<form action="" method="get">
<fieldset>
<input type="submit" name="price" value="500р">
<input type="submit" name="price" value="1000р">
<input type="submit" name="price" value="5000р">
</fieldset>
</form>
<form action="" method="get">
<fieldset>
<input type="text" name="custom_price" placeholder="Своя цена">
<input type="submit" name="price_btn">
</fieldset>
</form>
Вариант с выбором
<h3>Выбор из цен</h3>
<form action="" method="get">
<fieldset>
<label><input type="radio" name="price" value="500"> 500р</label>
<label><input type="radio" name="price" value="1000"> 1000р</label>
<label><input type="radio" name="price" value="5000"> 5000р</label>
<input type="text" name="other_price" placeholder="Своя цена">
<input type="submit" name="price_btn">
</fieldset>
</form>
Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости