In my template blade
I have:
{{ Form::select('idnumero', $numero, old('idnumero'), ['id'=>'numero']) }}
I want to use the old('idnumero')
in jquery, is there any way?
In my template blade
I have:
{{ Form::select('idnumero', $numero, old('idnumero'), ['id'=>'numero']) }}
I want to use the old('idnumero')
in jquery, is there any way?
You assign it to a data attribute, in Blade
{{ Form::select('idnumero', $numero, old('idnumero'),
['id'=>'numero', 'data-oldvalue'=> old('idnumero')]) }}
And then in jQuery you read it like that
var numeroOldValue = $('#numero').data('oldvalue');
A functional example with static html (here the old value is 1):
$('#numero').on('change', function() {
var oldValue = $(this).data('oldvalue');
var selValue = $(this).val();
console.log("old:", oldValue, "actual:", selValue);
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="numero" data-oldvalue="1" name="idnumero">
<option value="0">A</option>
<option value="1" selected="selected">B</option>
<option value="2">C</option>
<option value="3">D</option>
</select>