Foros del Web » Programando para Internet » Javascript »

problema con php y java

Estas en el tema de problema con php y java en el foro de Javascript en Foros del Web. hola a todos, tengo un problema con una funcion java en un php. Quiero que sobre un texto almacenado en la variable Código: <?$texto?> se ...
  #1 (permalink)  
Antiguo 22/01/2008, 04:35
 
Fecha de Ingreso: octubre-2007
Mensajes: 24
Antigüedad: 16 años, 6 meses
Puntos: 0
problema con php y java

hola a todos,

tengo un problema con una funcion java en un php. Quiero que sobre un texto almacenado en la variable
Código:
<?$texto?>
se pueda crear un enlace

la funcion es la siguiente:

Código:
<script>

function inslink(texto){
var input = document.form1.txttexto;
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(start, end);
var my_link = prompt("Enter URL:","http://");
if (my_link != null) {
if(insText.length==0){
insText=my_link;
}
input.value = input.value.substr(0, start) +"[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>

y el php:


Código:
<input type="button" name="txttexto" value="INSERTAR UN ENLACE" onClick="inslink(<?=$texto?>)"/>
<textarea name="txttexto" cols="90" rows="10" id="txttexto" ><?=$texto?></textarea>
Al ejecutarlo me aparece un mensaje que dice:


'hola caracola' no está definido, siendo 'hola caracola' el registro almacenado en <?=$texto?>

alguien puede ayudarme??
  #2 (permalink)  
Antiguo 22/01/2008, 04:59
Avatar de McBlink  
Fecha de Ingreso: noviembre-2006
Ubicación: $ARG->LaPampa()
Mensajes: 1.694
Antigüedad: 17 años, 5 meses
Puntos: 23
Re: problema con php y java

Prueba en lugar de

<?=$texto?>

poner

<?php echo $texto; ?>
__________________
Recuerda usar el highlight para mostrar código
mauricioblint.com
  #3 (permalink)  
Antiguo 22/01/2008, 05:04
 
Fecha de Ingreso: octubre-2007
Mensajes: 24
Antigüedad: 16 años, 6 meses
Puntos: 0
Re: problema con php y java

Sigue sin funcionar, ¿alguien sabe donde esta el error?
  #4 (permalink)  
Antiguo 22/01/2008, 10:11
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Re: problema con php y java

Recuerda que los parametros si son de texto, debes de escaparlos:
Código:
onClick="inslink('<?=$texto?>');"
.
Saludos.

PD Tu tema es de JavaScript mas que de PHP así que te muevo al foro correcto.
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 13:55.