Foros del Web » Programando para Internet » Javascript »

pulsar una tecla y que lo escriba en una pantalla

Estas en el tema de pulsar una tecla y que lo escriba en una pantalla en el foro de Javascript en Foros del Web. <HTML> <HEAD> <TITLE> Foro</TITLE> </HEAD> <BODY> <script type="text/javascript"> function message (t1, t2) { p = document.createElement ('P') strong = document.createElement ('STRONG') p.appendChild (strong) strong.appendChild (document.createTextNode ...
  #1 (permalink)  
Antiguo 29/12/2008, 10:09
 
Fecha de Ingreso: octubre-2008
Mensajes: 18
Antigüedad: 15 años, 6 meses
Puntos: 0
pulsar una tecla y que lo escriba en una pantalla

<HTML>
<HEAD>
<TITLE> Foro</TITLE>
</HEAD>

<BODY>
<script type="text/javascript">

function message (t1, t2) {
p = document.createElement ('P')
strong = document.createElement ('STRONG')
p.appendChild (strong)
strong.appendChild (document.createTextNode (t1))
br = document.createElement ('BR')
p.appendChild (br)
p.appendChild (document.createTextNode (t2))
document.getElementsByTagName ('BODY')[0].appendChild (p)
}

</script>

<style type="text/css">

label {display:block}

</style>

</head>
<body>
<div>
<input name="button" value="a" onclick="message('a')" type="button">
<input name="button" value="b" onclick="message('b')" type="button">
<input name="button" value="c" onclick="message('c')" type="button">
</div>
</form>

</body>
</html>

Mi duda es la siguiente: ¿se puede hacer esto con textarea en lugar de botones? en caso afirmativo, ¿decirme cómo?

Última edición por gamers; 29/12/2008 a las 10:45 Razón: explicación
  #2 (permalink)  
Antiguo 29/12/2008, 10:12
 
Fecha de Ingreso: octubre-2008
Mensajes: 18
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: pulsar una tecla y que lo escriba en una pantalla

Quiero hacer una especie de foro o minichat. Si álguien sabe cómo se hace, decirmelo. Gracias.

Última edición por gamers; 29/12/2008 a las 10:46 Razón: ejemplo
  #3 (permalink)  
Antiguo 29/12/2008, 17:11
Avatar de JoseTejada  
Fecha de Ingreso: diciembre-2007
Ubicación: Peru.Lima.Cercado.MDuarez.Granaderos172
Mensajes: 218
Antigüedad: 16 años, 4 meses
Puntos: 11
Respuesta: pulsar una tecla y que lo escriba en una pantalla

Ehmm sorry gamerz, no c si he entendido bien tu pregunta...pero derrepente esto sirva :S...
puedes cambiar el evento onCLick, onKeyPress, onFocus, etx; por cualkier otro...aki ta el codigo:
Código HTML:
<HTML>
<HEAD>
<TITLE> Foro</TITLE>
</HEAD>

<BODY>
<script type="text/javascript">

function message (t1, t2) {
    p = document.createElement ('P')
    strong = document.createElement ('STRONG')
    p.appendChild (strong)
    strong.appendChild (document.createTextNode (t1))
    br = document.createElement ('BR')
    p.appendChild (br)
    p.appendChild (document.createTextNode (t2))
    document.getElementsByTagName ('BODY')[0].appendChild (p)
}

</script>

<style type="text/css">

label {display:block}

</style>

</head>
<body>
<div>
<input name="button" value="a" onKeyPress="message(this.value)" type="text">
<input name="button" value="b" onclick="message(this.value)" type="text">
<input name="button" value="c" onFocus="message(this.value)" type="text">
</div>
</form>

</body>
</html> 
Porfa, responde si se soluciono... Bye
  #4 (permalink)  
Antiguo 29/12/2008, 19:58
Avatar de Fernand0  
Fecha de Ingreso: septiembre-2005
Ubicación: Buenos Aires
Mensajes: 610
Antigüedad: 18 años, 7 meses
Puntos: 19
Respuesta: pulsar una tecla y que lo escriba en una pantalla

Código PHP:
<HTML>
<
HEAD>
<
TITLEForo</TITLE>
</
HEAD>

<
BODY>
<
script type="text/javascript">

function 
send(bytosendwin) {
    var 
to=document.getElementById(tosend);
    var 
win=document.getElementById(win);
    
win.innerHTML+=by+': '+to.value+'\n';
    
to.value=''to.focus();
}

</script>

<style type="text/css">

label {display:block}

</style>

</head>
<body>
<div>
<textarea id="win" cols="60" rows="6"></textarea>
<input id="tosend" type="text" style="width: 437px;">
<input type="button" value="Enviar" onclick="send('Fernando', 'tosend', 'win');">
</div>
</form>

</body>
</html> 
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:36.