Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript

Status
Not open for further replies.

ratzp

Programmer
Joined
Dec 30, 2005
Messages
49
Location
IN
I have a select control written in HTML which has multiple selection..

Those values selected from the list has to copied to Text box..

Want a client side code written in JavaScript

Ratish

 
hi - dont know if this will help but the code below produces a combo from a database with id and values.
on change of the combo the value will be put into a text box

function - put value into textbox
Code:
<script language="JavaScript">
function getvalue(){
    var s = document.calc.x_warrid;
    var myVar = s.options[s.selectedIndex].text;
    document.form.x_textbox.value = myVar;
}
</script>

draws combo and fills with db data
Code:
<%
combo = "<select name='combo' id='select' onchange = 'getvalue()'>
<option value=''>None</OPTION>"

sqlwrk = "SELECT `dataid`, `data` FROM `yourtable`"
Set rswrk = Server.CreateObject("ADODB.Recordset")
rswrk.Open sqlwrk, conn, 1, 2

If Not rswrk.Eof Then
    datawrk = rswrk.GetRows
    rowswrk = UBound(datawrk, 2)
    For rowcntwrk = 0 To rowswrk
    combo = combo & "<option value='" & datawrk(0, rowcntwrk) & "'" 

        If CStr(datawrk(0, rowcntwrk)&"") = CStr(comboid&"") Then
        
           combo = combo & " selected"
        End If
        combo = combo & ">" & datawrk(1, rowcntwrk) & datawrk(2, rowcntwrk) &  "</option>"
    Next
End If
rswrk.Close
Set rswrk = Nothing
combo = combo & "</select>"
Response.Write combo
%>

textbox
Code:
<input type="text" id="x_textbox" name="x_textbox" value="<%= Server.HTMLEncode(x_textbox&"") %>">
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top