0

Hi one and all,
I am using C#.net language in asp.net framework using visual studio 2008. I have one checkbox as input control and two textboxes named textbox1 and textbox2 as asp controls. First the client needs to type something in textbox1 and after that the client needs to check the input checkbox. Then the text in textbox2 should be as same as that of textbox1. How to write javascript for this. The following did not work:
I have given onclick=display() near input control of checkbox:
I have written javascript as follows:
document.getElementById("textbox1").innertext = document.getElementById("textbox2").innertext .
Please help me thanx in advance

3
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by happyns
0

Give this a shot:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SignUp.aspx.cs" Inherits="daniweb.asp.SignUp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
	<script type="text/javascript">
		function copyValues() {
			document.getElementById("<%=TextBox2.ClientID%>").value = document.getElementById("<%=TextBox1.ClientID%>").value;
	}
	</script>

    <form id="form1" runat="server">
    <div>
    	<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    	<br />
    	<asp:CheckBox ID="CheckBox1" runat="server" Text="Copy" />
    	<br />
    	<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>
0

Thanx mail2saion for ur co-operation. I have used master pages in my project. But I did not write the code in the master page. I have written the following code in aspx page and got the correct output.

if (document.getElementById("<%=textbox1.ClientID%>").value!="")
 document.getElementById("<%=textbox2.ClientID%>").value = document.getElementById("<%=textbox1.ClientID%>").value

Edited by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

0

Thanx sknake for your reply. I already got the output. Anywayz my code is as same as yours

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.