Reputation: 4630
My Code:
<script type="text/javascript">
$(document).ready(function () {
$('#<%= chkCheckedSame.ClientID %>').change(function () {
if (document.getElementById('<%=chkCheckedSame.ClientID %>').checked) {
$('#<%=ShippingFirstName.ClientID %>').val
($('#<%=BillingFirstName.ClientID %>').val()); //working
$('#<%=ShippingLastName.ClientID %>').val
($('#<%=BillingLastName.ClientID %>').val());//working
alert($('#<%=BillingCountry.ClientID %>').val());
$('#<%=ShippingCountry.ClientID %> :selected').val
($('#<%=BillingCountry.ClientID %> :selected').val()); //Notworking
}
else {
}
});
});
</script>
What i'm tried:
Try1:
$('#<%=ShippingCountry.ClientID %> :selected').val
($('#<%=BillingCountry.ClientID %> :selected').val());
Try2:
$('#<%=ShippingCountry.ClientID %> :selected').text
($('#<%=BillingCountry.ClientID %> :selected').text());
Try3:
$('#<%=ShippingCountry.ClientID %>').val
($('#<%=BillingCountry.ClientID %>').val());
Fiddle: http://jsfiddle.net/jqpv8t54/
Upvotes: 1
Views: 428
Reputation: 148110
You need to use option with selected.
For value of option
($('#<%=BillingCountry.ClientID %> option:selected').val());
For text of option
$('#<%=BillingCountry.ClientID %> option:selected').text();
You may have other thing that are stopping the desired output, e.g.
$('#<%=ShippingFirstName.ClientID %>').val
will be syntax error. $('#<%=ShippingFirstName.ClientID %>').val
should be $('#<%=ShippingFirstName.ClientID %>').val();
Upvotes: 1