Mi scuso anticipatamente per il banale problema, ma sono un neofita che ha appena scoperto la bellezza e la plasticità di Javascript e mi sto cimentando.
Ho una pagina .ASP in cui ho dei controlli di tipo select e vorrei riuscire a visualizzare in un campo input text il campo chiave di una controllo di tipo Select.
Ho associato al controllo select per l'evento onchange una function javascript che non viene eseguita.
Vi chiederei di aiutarmi per capire il problema.
Grazie anticipate.
Moreno
Allego il codice della pagina .ASP
Resto ovviamente a disposizione per ogni eventuale chiarimento.
<%
@ LCID=1040
xDb_Conn_Str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "db\ARKPIF.mdb" & ";"
dim conn,rs,Strsql,Funzione
%>
<%
' Initialize common variables
x_Matricola_Dip = Null
x_Cognome_Dip = Null
x_Nome_Dip = Null
x_Grado_Dip = Null
x_C_Gruppo = Null
x_C_Mansione = Null
x_Stato = Null
x_NOTE_Dip = Null
x_Data_Assunzione = Null
x_Data_Fine = Null
x_Data_Ultimo_Spostamento = Null
x_User_Id_Dip = Null
x_Password_Dip = Null
x_DataULogin = Null
x_StatoLogin = Null
x_UserLevel = Null
x_e_Mail = Null
x_Sesso = Null
sAction = Null
%>
<%
Response.Buffer = True
' Load key from QueryString
Funzione = Request.QueryString("Func")
x_Matricola_Dip = Request.QueryString("Matricola_Dip")
' Get action
If sAction = "" Or IsNull(sAction) Then
sAction = "I" ' Display with input box
Else
' Get fields from form
sAction = Request.Form("H_Function")
x_Matricola_Dip = Request.Form("x_Matricola_Dip")
x_Cognome_Dip = Request.Form("x_Cognome_Dip")
x_Nome_Dip = Request.Form("x_Nome_Dip")
x_Grado_Dip = Request.Form("H_Grado_Dip")
x_C_Gruppo = Request.Form("H_C_Gruppo")
x_Stato = Request.Form("H_Stato")
x_NOTE_Dip = Request.Form("x_NOTE_Dip")
x_User_Id_Dip = Request.Form("x_User_Id_Dip")
x_UserLevel = Request.Form("H_UserLevel")
x_e_Mail = Request.Form("e_Mail")
x_Sesso = Request.Form("H_Sesso")
End If
' Open connection to the database
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
Select Case sAction
Case "I": ' Get a record to display
If Not LoadData() Then ' Load Record based on key
Session(ewSessionMessage) = "Records non trovati"
conn.Close ' Close Connection
Set conn = Nothing
Response.Clear
Response.Redirect "Elenco.asp"
End If
Case "M": ' Update
If EditData() Then ' Update Record based on key
Session(ewSessionMessage) = "Record aggiornato con successo"
conn.Close ' Close Connection
Set conn = Nothing
Response.Clear
Response.Redirect "Elenco.asp"
End If
' da fare
Case "D": ' delete
If DeleteData() Then ' Update Record based on key
Session(ewSessionMessage) = "Record cancellato correttamente"
conn.Close ' Close Connection
Set conn = Nothing
Response.Clear
Response.Redirect "Elenco.asp"
End If
End Select
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Nuova pagina 1</title>
<script type="text/javascript">
function SalvaSelCombo(quale) {
window.document.forms[0].elements["H_Stato"].value = quale;
break;
}
</script>
</head>
<body>
<form name="formGestione" id="fGestione" action="G.asp" method="post" >
<input type="hidden" name="H_Function" value="<%= sAction %>">
<table class="ewTable" align="center" border="0">
<tr>
<td>
<div class="form_description"><h2>Situazione Anagrafica</h2></div>
</td>
</tr>
</table>
<br>
<br>
<table class="ewTable" align="left" border="0">
<div id="DatiGestione">
<tr>
<td>
<label>Nag</label>
</td>
<td>
<input name="x_Matricola_Dip" size="5" maxlength="5" disabled="disabled" value="<%= x_Matricola_Dip %>">  <input name="x_Cognome_Dip" size="30" value="<%= Server.HTMLEncode(x_Cognome_Dip&"") %>">  <input name="x_Nome_Dip" size="30" value="<%= Server.HTMLEncode(x_Nome_Dip) %>">
</td>
</tr>
<tr>
<td>
<label>Stato</label>
</td>
<td>
<select name="Stato" id="elem_Stato" onChange="SalvaSelCombo(this.value);">
<option value="" selected="selected"></option>
<%
Strsql = "SELECT T_Stato_Anadip.C_Stato_Anadip, T_Stato_Anadip.D_Stato_Anadip " & _
"FROM T_Stato_Anadip " & _
"ORDER BY T_Stato_Anadip.D_Stato_Anadip"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open Strsql, conn
do until rs.EOF
if x_Stato = rs.Fields("C_Stato_Anadip") then
Response.Write "<option value = '" & rs.Fields("C_Stato_Anadip") & "' SELECTED='Selected'>" & rs.Fields("D_Stato_Anadip") & "</option>"
else
Response.Write "<option value = " & rs.Fields("C_Stato_Anadip") & ">" & rs.Fields("D_Stato_Anadip") & "</option>"
end if
rs.MoveNext
loop
rs.Close
Set rs = Nothing
%>
</select>
</td>
<td>
<input disabled="disabled" size="10" name="ModStato">
</td>
<td>
<input type="text" size="5" name="H_Stato" id="H_Stato" value="">
</td>
</tr>
</table>
<table border="0" align="center" >
<tr>
<td>
<input type="submit" name="btnAction" id="btnAction" value="MODIFICA">
</td>
<td>
<input type="reset" value="Reset" />
</td>
</tr>
</table>
</form>
<%
'-------------------------------------------------------------------------------
' Function LoadData
Function LoadData()
' istruzioni per lettura su mdb e editazione campi
End Function
'-------------------------------------------------------------------------------
' Function EditData
Function EditData()
' istruzioni per Modifica dati su mdb
End Function
'-------------------------------------------------------------------------------
' Function DeleteData
Function DeleteData()
' istruzioni per Cancellazione dati su mdb
End Function
%>
</body>
</html>