anyway to do this without post back to server
Hi I have a dropdown box with entries like
AY Activity Yellow
AB Activity Blue
AR Activity Red
This dropdown is followed by two text boxes and when the user selects AY I
would like to display the following in the text boxes
txbx1 [AY] txbx2 [Activity Yellow]
for AB Activity Blue
txbx1 [AB] txbx2 [Activity Blue]
So I am just spliting the string and displaying portions in each text box.
I was just wondering if there is a way to do this without posting back the
server on the dropdown SelectedIndexChanged event?
Thanks
--
Paul G
Software engineer.
RE: anyway to do this without post back to server
yes, its simple javascript.
<script>
function doDropChange(e)
{
var txt1 = document.getElementById('<%=txt1.ClientID%>');
var txt2 = document.getElementById('<%=txt2.ClientID%>');
txt1.value = e.value.substr(0,2);
txt2.value = e.value.substr(3);
}
</script>
then in codebehind:
myDropDowm.Attributes["onchange"] = "doDropChange(this)";
-- bruce (sqlwork.com)
"Paul" wrote:
> Hi I have a dropdown box with entries like
>
> AY Activity Yellow
> AB Activity Blue
> AR Activity Red
>
> This dropdown is followed by two text boxes and when the user selects AY I
> would like to display the following in the text boxes
>
> txbx1 [AY] txbx2 [Activity Yellow]
> for AB Activity Blue
> txbx1 [AB] txbx2 [Activity Blue]
> So I am just spliting the string and displaying portions in each text box.
> I was just wondering if there is a way to do this without posting back the
> server on the dropdown SelectedIndexChanged event?
> Thanks
>
> --
> Paul G
> Software engineer.
RE: anyway to do this without post back to server
Thanks it works. For the code behind I used
if (!Page.IsPostBack)
{
this.dropdown.Attributes["onchange"] = "doDropChange(this)";
}
--
Paul G
Software engineer.
"bruce barker" wrote:
> yes, its simple javascript.
>
> <script>
> function doDropChange(e)
> {
> var txt1 = document.getElementById('<%=txt1.ClientID%>');
> var txt2 = document.getElementById('<%=txt2.ClientID%>');
> txt1.value = e.value.substr(0,2);
> txt2.value = e.value.substr(3);
> }
> </script>
>
> then in codebehind:
>
> myDropDowm.Attributes["onchange"] = "doDropChange(this)";
>
>
> -- bruce (sqlwork.com)
>
>
> "Paul" wrote:
>
> > Hi I have a dropdown box with entries like
> >
> > AY Activity Yellow
> > AB Activity Blue
> > AR Activity Red
> >
> > This dropdown is followed by two text boxes and when the user selects AY I
> > would like to display the following in the text boxes
> >
> > txbx1 [AY] txbx2 [Activity Yellow]
> > for AB Activity Blue
> > txbx1 [AB] txbx2 [Activity Blue]
> > So I am just spliting the string and displaying portions in each text box.
> > I was just wondering if there is a way to do this without posting back the
> > server on the dropdown SelectedIndexChanged event?
> > Thanks
> >
> > --
> > Paul G
> > Software engineer.