使用按钮传递元素的 id PHP

passing id of element with button PHP

我为我的一个朋友开发了一个赌博网站。 为此,用户可以输入他想下注的金额。在此之后,他单击了 81 张图像中的一张。现在我需要获取 "id" 哪个框被点击,我需要获取他输入的值。

这是游戏本身的截图:

如何设计表单? 我尝试使用它,但经过一番思考它没有意义:

 <form class="form-inline" method="POST" action="{{ action('Utility\PlayController@getPlay') }}">
          {!! csrf_field() !!}
          <div class="form-group">
              <label class="sr-only" for="exampleInputAmount"></label>
              <div class="input-group">
                <div class="input-group-addon">
                  <i class="fa fa-btc"></i>
                </div>
                <input type="text" name="amount" maxlength="11" class="form-control" id="exampleInputAmount" value="0.00010000">
              </div>
          </div>
          </br>
         @for ($i = 1; $i <= 81; $i++)
          <input type="hidden" name="id" value="{{$i}}">    
          <input type="image" name="submit" src="<?=asset('assets/img/box_closed.png')?>" border="0" alt="{{$i}}" />
         @endfor
  </form>

总而言之,当发送 POST 请求时,我需要获取在上面的字段中输入的值以及用户单击的框的 ID。

如果您想通过点击框提交,只需输入类型="submit",并适当地设置名称和值,然后您

 <form class="form-inline" method="POST" action="{{ action('Utility\PlayController@getPlay') }}">
      {!! csrf_field() !!}
      <div class="form-group">
          <label class="sr-only" for="exampleInputAmount"></label>
          <div class="input-group">
            <div class="input-group-addon">
              <i class="fa fa-btc"></i>
            </div>
            <input type="text" name="amount" maxlength="11" class="form-control" id="exampleInputAmount" value="0.00010000">
          </div>
      </div>
      </br>
     @for ($i = 1; $i <= 81; $i++)
      <input class="box-input" type="submit" name="id" value="{{$i}}">
      <img class="box-input-image" src="{{ asset('assets/img/box_closed.png') }}">
     @endfor
</form>

这将在此处放置一个图像,因此您需要使用 display:none 或其他方式将框输入隐藏在 CSS 中。或者你可以只使用 :after psuedo CSS 选择器

**use radio button behind image box using css
or 
in image box set there (alt) as value then on click on image

<img src="1.jpg" height="150" onclick="setCookie(this.alt)" value="1" alt="1">
<script>
function setCookie(val)
{
document.cookie = "whichBoxIsClicked="+val;
}
</script>
//get that cookie anywhere**