0

I'm Trying to get the value of Input Type range so that I can echo the output in if else.

My HTML and PHP

  <input id="mySlider" type="range" min="1" max="6" name="rangee" step="1" value="1" onchange="resizeImage();" style="width:500px;">
    <p>Width: <span id="demo">
      <?php
        $ranger = $_POST['rangee'];

        if($ranger == "1"){
          echo "39 inches";
        }else if($ranger == "2"){
          echo "39 inches";
        }else if($ranger == "3"){
          echo "54 inches";
        }else if($ranger == "4"){
          echo "60 inches";
        }else if($ranger == "5"){
          echo "76 inches";
        }else if($ranger == "6"){
          echo "72 inches";
        }
      ?>
    </span></p>

and this is for my java. nothing to do with maybe.

  function resizeImage() {
  var image = document.getElementById('img-wrapper'),
      ranger = document.getElementById('mySlider');
  image.style.width = 200*(mySlider.value / 1)+'px';
  }

Thank you in advance

Xiao
  • 13
  • 6
  • 1
    Why do you switch from `$range` to `$_POST[range]`? (The latter would throw a warning, by the way). Using a switch case might be slightly easier here. – aynber May 07 '19 at 16:37
  • Possible duplicate of [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) – aynber May 07 '19 at 16:38
  • if I am going to use switch case how can i do that sir aynber? – Xiao May 07 '19 at 16:40
  • [Here is the information on switch statements](https://www.php.net/manual/en/control-structures.switch.php) – aynber May 07 '19 at 16:44
  • I think it is not getting the value of input type=range. that's why in switch case still not working Sir aynber. – Xiao May 07 '19 at 16:47
  • Note that PHP processes before the page is rendered, and javascript after. `resizeImage` will not do anything with PHP. Which part of it is not working? (by the way, not everyone on the internet is a sir). – aynber May 07 '19 at 16:49
  • I apologize for that. i only want the output to get when the range will move to 3 it will echo the inches. – Xiao May 07 '19 at 16:52
  • `$_POST['rangee'] != $_POST[range] != $range` you have some issues with your variables. – Andreas May 07 '19 at 16:53

0 Answers0