How to convert val(sex) from javascript to php select option male or female
<script>
$(document).ready(function(){
$('#edit_gv').on('show.bs.modal', function (e) {
var id = $(e.relatedTarget).data('id');
var name = $(e.relatedTarget).data('name');
var sex = $(e.relatedTarget).data('sex');
//Can pass as many onpage values or information to modal
//Pass value to text
$('#edit_MSCB').val(MSCB);
$('#edit_Ten_GV').val(Ten_GV);
$('#edit_sex').val(sex);`enter code here`
//pass value to hrml
$('#edit_sex').html(sex);
});
});
</script>
<select name="edit_sex" id ="edit_sex" class="form-control">
<option value ="0">male</option>
<option value ="1">female</option>
</select>
How to convert val(sex) from javascript to php select option male or female..
thanks
var sexval = $('#sex').val();
you can use above code and get get value
var sex = (sexval == 1)?'female':'male';
As @Anish pointed out associate ids to your selection boxes, but if your server just puts the values sent from the Client in your user table or whatever I can put values like Käsekuchen
in there.
1. Press F12
2. Click on "Inspector"
3. Search for your checkbox
4. Edit ID of Male
5. Select Male
6. Now send "Käsekuchen" to the Server or anything else.
So have a server side script that checks if the values are correct and then you're safe. (Not-really)