Hello again,
I'm just at work and i've had all the help possible from colleages, googlin and books and no one seems to be able to help me. Basically i have a form made in VS 2005, ASP.NET2.0 wit vb. This form has 2 sections on the saem page, personal address and work address. All i have been trying to do is copy and paste the address from the personal to the company if a checkbox is checked using javascript.
Now i admit i am no javascript guru, but, i have managed to get this working using simple html, therefore proving my method works but when i associate it with .net textboxes it just seems to totally ignore everything.
Below is the test html code i made to prove this method works, it defo works in a simple html page with simple html controls:
<SCRIPT LANGUAGE="JavaScript">
// <!--
function shipsame(form)
{
if(form.copycheck.checked)
{
form.outtxt.value = form.intxt.value;
}
else
{
form.outtxt.value = " ";
}
}
//-->
</script>
</head>
<body>
<form name="blah">
<input id="copycheck" name="copycheck" type="checkbox" value="checkbox"
onClick="shipsame(this.form);">
Copy addresses<br />
<br />
Copy from
<input id="intxt" type="text" /><br />
<br />
Paste to
<input name="outtxt" type="text" />
</form>
</body>
</html>
That defo works but my code is a lot more complex as it is not simple html but asp.net2.
I have tried calling the txtboxes via their given id's - did not work
I have tried looking at the source code (notepad) and getting ct100$ blah blah id - didn't work
I have tried getting the 'name' from the source code - that didn't work.
This is what i have tried:
Remember, there is one checkbox(html) and 2 <asp:textbox>'s within a formview
function shipsame(form)
{
if(form.sameaddresscheck.checked)
{
//var publicaddress = frmIPR.ctl00$cpText$suppliergv$supplier_public_address1TextBox.Value;
//var contactaddress = frmIPR.ctl00$cpText$suppliergv$supplier_contact_address1TextBox.Value;
//var publicaddress = document.getElementById("ctl00$cpText$suppliergv$supplier_public_address1TextBox").innerText
//var contactaddress = document.frmIPR.getElementById("ctl00$cpText$suppliergv$supplier_contact_address1TextBox").innerText
//frmIPR.ctl00$cpText$suppliergv$supplier_public_address1TextBox.Value;
//var contactaddress = document.getElementById("supplier_contact_address1TextBox").Value; //form.supplier_contact_address1TextBox.Value = form.supplier_public_address1TextBox.Value; form.ctl00$cpText$suppliergv$supplier_public_address1TextBox.Value = form.ctl00$cpText$suppliergv$supplier_contact_address1TextBox.Value;
}
else
{
form.ctl00$cpText$suppliergv$supplier_public_address1TextBox.Value = "";
}
}
-->
</script>
It does seem to recognise that the checkboc has been checked,the .net code is as follows for each control:
<asp:TextBox ID="supplier_contact_address1TextBox" name="supplier_contact_address1TextBox" runat="server" Text='<%# Bind("supplier_contact_address1") %>' CssClass="formviewtxtboxes" MaxLength="50" Width="200px"></asp:TextBox></td>
<asp:TextBox ID="supplier_public_address1TextBox" name="supplier_public_address1TextBox" runat="server" Text='<%# Bind("supplier_public_address1") %>' CssClass="formviewtxtboxes" MaxLength="50" Width="200px"></asp:TextBox></td>
<input id="sameaddresscheck" type="checkbox"value="checkbox" onClick="shipsame(this.form);" title="Address same as above" lang="uk"> <b>Same address as above</b>
Please help me as i have a deadline and i've neva done any javascript before today - arrrr,lol.
I will have a look in the moring for replies and will be looking forward to reading peoples suggestions and opinions.
Regards
xx
