Support the ongoing development of Laravel.io →
Session Cache Blade
Last updated 2 years ago.
0

You can use this code for your form

{!! Form::select('numberOfChildren',range(0,10),old('numberOfChildren'),['id'=>'numberOfChildren']) !!}

And Jquery you should change

index = this.selectedIndex;

with

index = $(this).val();
0

Hi, the form is sent to another page, so when the submit button is pressed the values are stored correctly in the session but the children's ages are set back to default, being 1.

So I need the session values put back into the childrens ages.

0

I think this code is bestter for you

{!! Form::open(['url'=>'test']) !!}
{!! Form::select('numberOfChildren',range(0,10),null,['id'=>'numberOfChildren'])!!}
<div id="add_select">
    @for($i=0;$i<10;$i++)
        {!! Form::select('age_'.$i,range(1,14),null,['style'=>'display:none;','id'=>'age_'.$i,'class'=>'age_child'])!!}
    @endfor
</div>
{!! Form::submit('Submit')!!}
{!! Form::close()!!}
<script>
    $('#numberOfChildren').change(function(){
        var index = $(this).val();
        for(var u=0; u<index; u++){
            $('#age_'+u).show();
        }
    }).trigger('change');
</script>

I tested. It very ok

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ottz0 ottz0 Joined 15 Nov 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.