Logo JsDir.com [niente]
Bring Your Site To Life!!!
7 Gennaio 2009 - 1:21:03 - 23 scripters on-line! - La tua posizione nel sito: Tutorials/Passare dati fra form e finestre/
BedInLecce
Tutorials
Trasferire dati fra pagine diverse


Trasferire valori di campi form da una pagina ad un'altra contenute nello stesso frame

Supponiamo di avere un frameset costituito da due pagine, una superiore ed una inferiore:
<html>
<head>
</head>
<frameset rows="*,*">
  <frame name="top" src="top.htm">
  <frame name="bottom" src="bottom.htm">
  <noframes>
  <body>
  </body>
  </noframes>
</frameset>
</html>

Nella bottom.htm abbiamo un campo testo contenente un determinato valore che vogliamo trasferire in un'altro campo testo nella pagina top.htm
La pagina top.htm conterrā il seguente codice:
<html> 
<head> 
<title>top</title> 
</head> 
<body> 
<form method="POST" name="formtop"> 
  <p><input type="text" name="testotop" size="20"></p> 
</form> 
</body> 
</html> 

Nella pagina bottom.htm avremo invece il codice javascript che ci riporterā il valore dal campo testo "testobottom" nel campo "testotop" della pagina top.htm:
<html> 
<head> 
<title>bottom</title> 
<script language="javascript"> 
function tras(){ 
aa=top.frames[1].document.formbottom.testobottom.value; 
top.frames[0].document.formtop.testotop.value=aa; 
} 
</script> 
</head> 
<body> 
<form method="POST" name="formbottom"> 
  <p><input type="text" name="testobottom" size="20" value="15000"><br> 
  <input type="button" value="trasferisci" name="B1" onClick="tras()"></p> 
</form> 
</body> 
</html>





Per navigare correttamente il sito è necessario abilitare i cookies.
Enjoy Open Source!
th80_1

    javascript
 
 
 
          Segnala
          Preferiti





ffx1201