Foros del Web » Programando para Internet » Javascript »

Duda con BBCode

Estas en el tema de Duda con BBCode en el foro de Javascript en Foros del Web. Hola chic@s: ¿No sabreis si hay algo tipo bbcode pero para poder usarlo en campos input? He probado con el javascript que tiene panino en ...
  #1 (permalink)  
Antiguo 26/01/2008, 10:41
 
Fecha de Ingreso: abril-2003
Mensajes: 363
Antigüedad: 21 años
Puntos: 3
Duda con BBCode

Hola chic@s:

¿No sabreis si hay algo tipo bbcode pero para poder usarlo en campos input?
He probado con el javascript que tiene panino en su web (http://www.disegnocentell.com.ar/new...los.php?id=131) pero con campos input no funciona.

Saludos
  #2 (permalink)  
Antiguo 27/01/2008, 13:26
 
Fecha de Ingreso: octubre-2007
Mensajes: 24
Antigüedad: 16 años, 6 meses
Puntos: 0
Re: Duda con BBCode

hola yazo.

yo tambien he usado ese mismo codigo y tambien intente aplicarlo a un campo input y no lo conseguí, no me respetaba el ancho y alto del campo y el texto se quedaba fuera. siento no serte de ayuda
  #3 (permalink)  
Antiguo 27/01/2008, 14:30
 
Fecha de Ingreso: abril-2003
Mensajes: 363
Antigüedad: 21 años
Puntos: 3
Re: Duda con BBCode

Cita:
Iniciado por narayan Ver Mensaje
hola yazo.

yo tambien he usado ese mismo codigo y tambien intente aplicarlo a un campo input y no lo conseguí, no me respetaba el ancho y alto del campo y el texto se quedaba fuera. siento no serte de ayuda
No pasa nada, muchas gracias de todas formas.
  #4 (permalink)  
Antiguo 27/01/2008, 14:44
Avatar de Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Re: Duda con BBCode

La verdad no le veo demasiado sentido a colocarlo fuera de un área de texto. De todas maneras, es más fácil adaptarlo tomando como referencia no a bebecode sino a la faq 244.
Ejemplo:
Código PHP:
<html>
<
head>
<
title>Editor bbCode</title>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<
script>
function 
instag(tag){
var 
input document.form1.contenido;
if(
typeof document.selection != 'undefined' && document.selection) {
var 
str document.selection.createRange().text;
input.focus();
var 
sel document.selection.createRange();
sel.text "[" tag "]" str "[/" +tag"]";
sel.select();
return;
}
else if(
typeof input.selectionStart != 'undefined'){
var 
start input.selectionStart;
var 
end input.selectionEnd;
var 
insText input.value.substring(startend);
input.value input.value.substr(0start) + '['+tag+']' insText '[/'+tag+']'input.value.substr(end);
input.focus();
input.setSelectionRange(start+2+tag.length+insText.length+3+tag.length,start+2+tag.length+insText.length+3+tag.length);
return;
}
else{
input.value+=' ['+tag+']Reemplace este texto[/'+tag+']';
return;
}
}
function 
inslink(){
var 
input document.form1.contenido;
if(
typeof document.selection != 'undefined' && document.selection) {
var 
str document.selection.createRange().text;
input.focus();
var 
my_link prompt("Enter URL:","http://");
if (
my_link != null) {
if(
str.length==0){
str=my_link;
}
var 
sel document.selection.createRange();
sel.text "[a href=\"" my_link "\"]" str "[/a]";
sel.select();
}
return;
}else if(
typeof input.selectionStart != 'undefined'){
var 
start input.selectionStart;
var 
end input.selectionEnd;
var 
insText input.value.substring(startend);
var 
my_link prompt("Enter URL:","http://");
if (
my_link != null) {
if(
insText.length==0){
insText=my_link;
}
input.value input.value.substr(0start) +"[a href=\"" my_link +"\"]" insText "[/a]"input.value.substr(end);
input.focus();
input.setSelectionRange(start+11+my_link.length+insText.length+4,start+11+my_link.length+insText.length+4);
}
return;
}else{
var 
my_link prompt("Ingresar URL:","http://");
var 
my_text prompt("Ingresar el texto del link:","");
input.value+=" [a href=\"" my_link "\"]" my_text "[/a]";
return;
}
}
</script>
</head>

<body>
<form name="form1" method="post" action="">
<input type="button" name="Submit" value="B" onClick="instag('b')">
<input type="button" name="Submit3" value="U" onClick="instag('u')">
<input type="button" name="Submit4" value=" I " onClick="instag('i')">
<input type="button" name="Submit2" value="LINK" onClick="inslink()">
<br>
<input id="contenido" name="contenido" type="text" size="80">
</form>
</body>
</html> 
  #5 (permalink)  
Antiguo 27/01/2008, 15:17
 
Fecha de Ingreso: abril-2003
Mensajes: 363
Antigüedad: 21 años
Puntos: 3
Re: Duda con BBCode

Muchas Gracias Panino, como siempre un 10.
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 03:18.