Come faccio a memorizzare in una variabile o in un array un valore inserito in un campo input da un utente?
Come faccio a memorizzare in una variabile o in un array un valore inserito in un campo input da un utente?
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="JavaScript" type="text/JavaScript">
function prova(){
var frm= document.getElementsByTagName('form')[0];
var miaVar=frm.elements[0].value;
alert(miaVar);
}
</script>
</head>
<body>
<form action="" method="get" name="frm">
<input name="provaInput" type="text" />
<input onclick="prova();" name="schizza" type="button" value="schizza" />
</form>
</body>
</html>
![]()
Without faith, nothing is possible. With it, nothing is impossible
http://ilwebdifabio.it
Questo è il codice di esempio praticamente i risultati della variabili devono sommarsi e apparire nella cella della tabella
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="stile.css" />
<script src="e-commerce.js" type="text/javascript"></script>
<title>Esempio di calcolo spesa</title>
</head>
<body>
<h1>Shopping</h1>
<div id="box">
<h2>Jeans</h2>
[img]immagini/06levis.jpg[/img]
Costo 50 €</p>
<form method="post" action="#" id="modulo1">
<fieldset>
<legend>Articoli uomo</legend>
<label for="art1">Numero di jeans </label><input type="text" id="art1" size="3" onblur="calcolo" />
</fieldset>
</form>
</div>
<div id="box2">
<h2>Camicia</h2>
[img]immagini/camiciauomo_jeans_a2petto.gif[/img]
Costo 30 €</p>
<form method="post" action="#" id="modulo2">
<fieldset>
<legend>Articoli uomo</legend>
<label for="art2">Numero di camicie </label><input type="text" id="art2" size="3" onblur="calcolo" />
</fieldset>
</form>
</div>
<div id="box3">
<table>
<caption>Totale</caption>
<tr>
<td >Euro</td>
<td id="euro">0</td>
</tr>
<tr>
<td>Dollaro</td>
<td id="dollaro">0</td>
</tr>
</table>
</div>
</body>
</html>