Link to home
Start Free TrialLog in
Avatar of csaexperts
csaexpertsFlag for United States of America

asked on

Populating Text fields from dropdown choice

I have a table that I loop through to populate a dropdown list and I want to populate text fields with data based on what the user selects from the dropdown menu. The data I want to output in the textfields is not the same as the value set in the option fields, but does correspond with that row. Any help is much appreciated.
Thanks
Avatar of Anil Golamari
Anil Golamari
Flag of United States of America image

<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">
  function AssigntoTextBox(dropDown) {
   dropDown.parentNode.parentNode.childNodes[1].childNodes[0].value = dropDown.value;
  }
 </script>

     
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:TextBox runat="server" ID="tbName" />

        <asp:DropDownList ID="ddlName" onchange="AssigntoTextBox(this)" runat="server">
      <asp:ListItem>AAA</asp:ListItem>
      <asp:ListItem>BBB</asp:ListItem>
      <asp:ListItem>CCC</asp:ListItem>
     </asp:DropDownList>

   
    </div>
    </form>
</body>
Avatar of csaexperts

ASKER

Thanks lucky85 for the help, tried the code which you have mentioned about but it didnt work.
Thanks
It worked for me. What I did was, I had a drop down to a page and a text box. Now when ever a user changes the selection on the drop down that value will be apperead on the textbox. Are you looking something like this right?
Not exactly; when the user selects from the dropdown menu. The data I want to output in the textfields is not the same as the value set in the option fields, but does correspond with that row.
SOLUTION
Avatar of docnica
docnica
Flag of Panama image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Able to solve the problem using ajax
Able to solve the problem using Ajax