Here is my script
<input type="text" id="teamleader-default" value="${foo.teamLeaderId}/${foo.teamLeaderFirstName} ${foo.teamLeaderLastName}" />
<script type="text/javascript">
$(document).ready(function(){
var teamleader = $('#teamleader-default').val();
var tl_details = teamleader.split("/");
$('#teamleader-default').prop('type', 'hidden');
$("#update").submit(function() {
if ($('#ParentDD :selected').text() == "Engineer") {
var tmp0 = $('#teamleader').val(tl_details[1]);
var tmp1 = $('#teamleaderId').val(tl_details[0]);
alert(tmp0);
alert(tmp1);
} else {
var tmp2 = $('#teamleader').val('');
var tmp3 = $('#teamleaderId').val(0);
alert(tmp2);
alert(tmp3);
}
});
});
</script>
The problem is that I can't assign a value for both the teamleader and the teamleader ID
$('#teamleader').val(tl_details[1]);
$('#teamleaderId').val(tl_details[0]);
instead the value it contains is just saying "Object object" like the one in this image:
Can anyone help me on how to assign a value for the team leader.
Again a big thanks for those who could help me.