Test Foro de elhacker.net SMF 2.1

Programación => Desarrollo Web => Mensaje iniciado por: Ori-chan en 11 Enero 2013, 16:59 PM

Título: [PHP/JS] ¿Trasladar variables?
Publicado por: Ori-chan en 11 Enero 2013, 16:59 PM
Código (lenguage) [Seleccionar]
<!Doctype html>
<html>
<head>
</head>
<script type="text/javascript">
function abc ()
var fas=$_REQUEST['nombre'];
document.write (fas);
</script>
<body>
<form method="post">
  Ingrese algo:
  <input type="text" name="frase">
  <br>
  <input type="submit" value="confirmar">
</form>
<input type="button" onclick="abc()">
</body>
</html>


Se supone que tiene que poner la frase que escribas en el recuadro.
Título: Re: [PHP/JS] ¿Trasladar variables?
Publicado por: Shell Root en 11 Enero 2013, 17:03 PM
1. Con jQuery sería más fácil.
2. Supongo que,...
Código (javascript) [Seleccionar]
function js(){
var hola = <?php echo "hola"?>;
}
Título: Re: [PHP/JS] ¿Trasladar variables?
Publicado por: Ori-chan en 11 Enero 2013, 17:33 PM
No sabia que se podía hacer eso, gracias!  ;D
Título: Re: [PHP/JS] ¿Trasladar variables?
Publicado por: Ori-chan en 12 Enero 2013, 15:33 PM
Código (lenguage) [Seleccionar]
<!Doctype html>
<html>
<head>
</head>
<script type="text/javascript">
function abc ()
var fas= <?php $_REQUEST['frase'?>;
document.write(fas);
</script>
<body>
<form method="post">
Ingrese algo:
<input type="text" name="frase">
<br>
<input type="submit" value="confirmar">
</form>
<input type="button" onclick="abc()">
</body>
</html>


Sige sin funcionar  :huh:

Título: Re: [PHP/JS] ¿Trasladar variables?
Publicado por: Shell Root en 14 Enero 2013, 03:24 AM
Es,
Código (php) [Seleccionar]
<?php echo $_REQUEST['frase']; ?>
ó
Código (php) [Seleccionar]
<?= $_REQUEST['frase']; ?>