Click here to Skip to main content
14,739,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

var name=$(this).attr('id');
var txt= $("input[id$='txtShareMessage']").val(name);

when i used above script lines to assign the value to a textbox using jquery and textbox is placed in repeator not getting the value and am getting object [object] in alert how can i resolve to assign value to textbox which is in repeator

1 solution

var txt= $("input[id$='txtShareMessage']").val(name);

If you will alert "txt" like alert(txt);, you will get object [object]. That is because it is a TextBox actually and you are holding it in txt object.

You should read the value by...


See how it is working.
[Demo] Alert TextBox value after assigning Value to it[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900