[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 723
  • Last Modified:

Populate textbox on radiobutton click

I have a texbox named "ServeeAddress1" with text in it, which I need to send to the 2nd textbox, "ServedAddress" when i click a radiobutton, so they both then have the same text. Here is the code I tried and it is not working. I get an error in the javascript that says, "object required"

<script type="text/javascript" language="javascript">
function setText()
{
document.getElementById("ctl00_ContentPlaceHolder1_tabcontainer1_tabpanel4_ServeeAddress1").value == document.getElementById("ctl00_ContentPlaceHolder1_tabcontainer1_tabpanel5_ServedAddress").value;
}
</script>

<asp:RadioButton ID="Radio1" runat="server" Text="Address 1" onclick="setText();"  />

<asp:textbox id="ServeeAddress1" runat="server"/>
<asp:textbox id="ServedAddress runat="server"/>

0
mlg101
Asked:
mlg101
1 Solution
 
Ryan ChongCommented:
>>document.getElementById("ctl00_ContentPlaceHolder1_tabcontainer1_tabpanel4_ServeeAddress1").value == document.getElementById("ctl00_ContentPlaceHolder1_tabcontainer1_tabpanel5_ServedAddress").value;

should be as:

document.getElementById("ctl00_ContentPlaceHolder1_tabcontainer1_tabpanel4_ServeeAddress1").value = document.getElementById("ctl00_ContentPlaceHolder1_tabcontainer1_tabpanel5_ServedAddress").value;

?
0
 
rhodesbCommented:
Two equals signs checks equality between two things (like in an if statement), 1 equals sign is for when you are assigning a value to something.
0
 
mlg101Author Commented:
OK, I tried that, thank you, but it still doesnt work. Now the error says document.getElementById is Null or not an object. any ideas?
0
 
ASPSQLServerCOMCommented:
could you please copy pastew the browser view source HTML
0
 
Ryan ChongCommented:
can help double check what is "ctl00_ContentPlaceHolder1_tabcontainer1_tabpanel4_ServeeAddress1" in your page? Is it a form element, or a layer (div), etc? if it's a layer, try use innerHTML instead, like:


document.getElementById("ctl00_ContentPlaceHolder1_tabcontainer1_tabpanel4_ServeeAddress1").innerHTML = "new value";


of course, before that, make sure object "ctl00_ContentPlaceHolder1_tabcontainer1_tabpanel4_ServeeAddress1" exists in your page?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now