Reputation: 551
I develope a kind of gambling site for a friend of me. For this a user can enter an amount he would like to bet. After this he clicks one of 81 images. Now I would need to get the "id" which box was clicked and I need to get the value he entered to bit.
Here's a screenshot of the game itself:
How to design the forms? I tried to use this, but after some thinking it won't make sense:
<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>
All in all when the POST request is send I need to get the value entered in the field above AND the id of the box user clicked.
Upvotes: 0
Views: 754
Reputation: 1904
If you want to submit on clicking a box, simply make the input type="submit", and set the name and value appropriately then you
<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>
This will place an image there so you need to make box-input hidden in your CSS using display:none or whatever. Or you could just use the :after psuedo CSS selector
Upvotes: 1
Reputation: 1676
**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**
Upvotes: 0