How to assign a value to a textbox through javascript?

 Posted by Kmandapalli on 12/4/2013 | Category: JavaScript Interview questions | Views: 3572 | Points: 40
Select from following answers:
  1. document.getElementById("<%=txt.ClientID %>").value = "tgfdt";
  2. document.getElementById("<%=txt.ClientID %>").Text= "tgfdt";
  3. document.getElementById("<%=txt.clientID %>").Text= "tgfdt";
  4. document.getElementById("<%=txt.clientID %>").value = "tgfdt";
  5. All Above

Show Correct Answer

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: vishalneeraj-24503 on: 1/10/2014 | Points: 10
Hi Kmandapalli,

Have you checked this? It will throw an error.
It will give syntax error.

The right syntax is:-

document.getElementById("<%=txt.ClientID%>").value = "tgfdt";

you have to append %> after ClientID.Then it will work.Please check at your end.
Posted by: Kmandapalli on: 1/10/2014 | Points: 10

Typing mistake. Thanks for checking.

Shree M.

Login to post response