Reputation:
I have to assign the value in a repeater column in such a way that upon assignment, the value in the repeater column becomes the current selection in the drop down.
I have the correct value to assign in $('#myname_' + rowIndex).text()
, but when I assign this value to the id.value of the dropdown - as shown below - the assignment has no effect. What am I doing wrong.
$("ctl00_ContentPlaceHolder1_myname").value = $('#myname_' + rowIndex).text();
Upvotes: 0
Views: 578
Reputation: 9080
Use:
$("ctl00_ContentPlaceHolder1_myname").val($('#myname_' + rowIndex).text());
Or
$("ctl00_ContentPlaceHolder1_myname")[0].value = $('#myname_' + rowIndex).text();
Upvotes: 1
Reputation: 1535
$("ctl00_ContentPlaceHolder1_myname").val($('#myname_' + rowIndex).text())
or
$("ctl00_ContentPlaceHolder1_myname")[0].value = $('#myname_' + rowIndex).text()
Upvotes: 0
Reputation: 21365
Have you tried using the val
function instead?
$("#ctl00_ContentPlaceHolder1_myname").val($('#myname_' + rowIndex).text());
The val
function can be used to get the value from the object if you use it without parameters
Upvotes: 1
Reputation: 18906
jQuery uses val()
, JavaScript (the HTML DOM object) uses value
.
Upvotes: 1