PDA

View Full Version : how to refresh?


molty
04-25-2003, 02:08 AM
hi.
imagine i have a textbox and below that i have a listbox with some records. if i choose a record in the listbox, i would like that choice to appear in the textbox above. how do i go abt it. i would like some help imediately.i am stuck..pls.. thanks

listbox name = Listbox 1 and textbox name = txtCGrp

smeagol
04-25-2003, 02:50 AM
Try this:

<form name="form1">
<INPUT TYPE="text" NAME="txtOutput">
<SELECT NAME="cboList" onchange="document.form1.txtOutput.value = this.value">
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
<option value="Option 4">Option 4</option>
<option value="Option 5">Option 5</option>
</SELECT>

molty
04-25-2003, 04:13 AM
can this be used in asp.net? and tis code should be in the textbox function?

raf
04-25-2003, 07:29 AM
i think you can do this better clientsided, with the code smeagol posted or something similar (plain Javascript).

Of course, a user can start messing that up, so i would only use the value from the dropdown in the asp page you post to

david7777
04-25-2003, 07:54 AM
Are you wanting to fill a form from a database when the user selects something else from the drop down?

If so - the best thing, i would imagine, would be to creqte the listbox in ASP.NET like so:

<asp:DropDownList id="ListBox1" runat="server" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" AutoPostBack="True">
</asp:DropDownList>

Obviously add in the data to be displayed in the list.

Then as server side code:

Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs)
' Do your database search on the selected option
' Put the results in an array / dataset / ... (Whatever suits you best)
' Then fill the form with the new information
' ie: txtCGrp.text = myArray("txtCGrp")
End Sub