lundi 4 février 2019

In same page, how to get value from radio button and use it for the coming radio button

In same page, how to get value from radio button and use it for the coming radio button.

Example:

OCountry OGender

If i selected Country, then the below radio button option will show:

OAmerica OEngland OAustralia OMalaysia

But all of this is before submit button. Is all in one page.

So below is my code. Can anyone give me some advise?

1.Blade.

    <script type="text/javascript">
    function show1(){
      document.getElementById('div1').style.display ='none';
    }
    function show2(){
      document.getElementById('div1').style.display = 'block';
    }
    </script>
{!! Form::open(['action'=>'PostsController@store','method'=>'POST']) !!}
            <h2>Hi,</h2><br>
            <div class="form-group">
                <br>
                    @foreach($rkeys as $rkey)
                    @if($rkey->status == "1")
                    <div class="form-check form-check-inline">
                        <input onclick="show1()" class="form-check-input" type="radio" name="roomkey" hidden selected><br>
                            <input 
                            onclick="show2()" 
                            class="form-check-input" 
                            type="radio" 
                            name="roomkey" 
                            value="" 
                            disabled> 
                            <br></div>
                    @else
                    <div class="form-check form-check-inline">
                        <input onclick="show1()" class="form-check-input" type="radio" name="roomkey" hidden selected><br>
                    <input onclick="show2()" class="form-check-input"  type="radio" name="roomkey" value="" > <br></div>
                    @endif
                    @endforeach
            </div>
//so this is the after the 1st part of radio button form.
                <div id="div1" class="hide">
                <hr><p>Room Number:</p>
                @foreach ($room as $room)
                @foreach($rkeys as $rkey)
                @if($rkey->roomkey == $room->roomkey)
                <input type="checkbox" value="" name="roomNum">
                 &nbsp;
                @endif
                @endforeach
                @endforeach
                </div>
            <br>
            <input name="status" type="hidden" value="1">
            
        {!! Form::close() !!}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire