-3

How to get the value of a range input and pass it to a PHP variable ?

<input type=range min=0 max=100 value=50 name="price">
exchanger3145
  • 45
  • 1
  • 5

2 Answers2

3

The same way you get the value of any other input.

Put it in a form, submit the form, then use $_GET['fieldname'] (or $_POST).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Can i get that value somehow before submitting the form ? i mean i want to use it in the same page not another one – exchanger3145 Nov 02 '14 at 22:34
  • @exchanger3145 — Not with PHP. See http://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming – Quentin Nov 03 '14 at 06:56
2

index.php

<form action="check.php" method="POST">
    <input type="range" min="0" max="100" value="50" name="price">
    <button type="submit">Submit</button>
</form>

check.php

<?php

echo $_POST['price'];

?>
Nicholas Summers
  • 4,444
  • 4
  • 19
  • 35