Ver Mensaje Individual
  #3 (permalink)  
Antiguo 12/04/2007, 08:29
LinosINK
 
Fecha de Ingreso: diciembre-2004
Mensajes: 190
Antigüedad: 20 años, 4 meses
Puntos: 0
Re: duda sobre un pequeño error al llamar a una funcion con select case

Hola tammander, gracias por contestar.

Lo que cargo es un archivo .js que tiene una función que te crea la barra para negrita, cursiva, etc. parecida a la de este foro.

Te pongo la función por si te interesa:
Código:
function init(){
	incluidos=init.arguments;
	for(i=0;i<incluidos.length;i++){
		cuerpo=document.body.innerHTML;
		html="<table><tr><td valign=\"top\"> <img src=\"bbcode/buttons/bold.gif\" width=\"21\" height=\"20\" onclick=\"instag('b','"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onMouseOut=\"this.style.border='solid 1px #F7F7F7';\" style=\"border:solid 1px #F7F7F7;\" title=\"Negrita\">&nbsp;<img src=\"bbcode/buttons/underline.gif\" width=\"21\" height=\"20\" onclick=\"instag('u','"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #F7F7F7';\" style=\"border:solid 1px #F7F7F7;\" title=\"Subrayado\">&nbsp;<img src=\"bbcode/buttons/italic.gif\" width=\"21\" height=\"20\" onclick=\"instag('i','"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #F7F7F7';\" style=\"border:solid 1px #F7F7F7;\" title=\"Cursiva\">&nbsp;<img src=\"bbcode/buttons/link.gif\" width=\"21\" height=\"20\" onclick=\"inslink('"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #F7F7F7';\" style=\"border:solid 1px #F7F7F7;\" title=\"Insertar enlace\">&nbsp;<img src=\"bbcode/buttons/insertimage.gif\" width=\"21\" height=\"20\" onclick=\"captura_imag('"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #F7F7F7';\" style=\"border:solid 1px #F7F7F7;\" title=\"Insertar imagen\">&nbsp;<img src=\"bbcode/buttons/bullist.gif\" width=\"20\" height=\"20\" onclick=\"ins_imag('•','"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #F7F7F7';\" style=\"border:solid 1px #F7F7F7;\" title=\"Vi&ntilde;eta\" /></td><td valign=\"top\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><img src=\"bbcode/buttons/resize_0.gif\" width=\"21\" height=\"9\"  onclick=\"quitar('"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #F7F7F7';\" style=\"border:solid 1px #F7F7F7;\" title=\"Disminuir tama&ntilde;o\"></td></tr><tr><td><img src=\"bbcode/buttons/resize_1.gif\" width=\"21\" height=\"9\" id=\"quita\"  onclick=\"agregar('"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #F7F7F7';\" style=\"border:solid 1px #F7F7F7;\" title=\"Aumentar tama&ntilde;o\"></td></tr></table></td></tr></table><textarea name=\""+incluidos[i]+"\" cols=\"70\" rows=\"5\" id=\""+incluidos[i]+"\">";

		pat="<textarea+[^>]*"+incluidos[i]+"+[^<]+"; 	
		patron =new RegExp(pat,"gi");
		coincidencias=new Array();
		coincidencias=cuerpo.match(patron);
		for(j=0;j<coincidencias.length;j++){
			result=new Array();
			result=coincidencias[j].match(/\s+id=[^>\s]+/g);
			result[0]=result[0].split('"').join(''); 
			result[0]=result[0].split('id=').join(''); 
			result[0]=result[0].split(' ').join(''); 
			if(result[0]==incluidos[i]){
				valor=new Array();
				valor2='';
				valor=coincidencias[j].split('>');
				if(valor.length>1){
						for(k=1;k<valor.length;k++){
							valor2+=valor[k];
						}
					}
				cuerpo2=cuerpo.split(coincidencias[j]);
			}
		}
		
		document.body.innerHTML=cuerpo2[0]+html+valor2+cuerpo2[1];
	}
}
function instag(tag,campo){
	var input = document.getElementById(campo);
		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(start, end);
			input.value = input.value.substr(0, start) + '<'+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(campo){

var input = document.getElementById(campo);

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) {

    var sel = document.selection.createRange();

            sel.text = "<a href=\"" + my_link + "\" target=\"_blank\">" + str + "</a>";

  }

  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) {

 input.value = input.value.substr(0, start) +"<a href=\"" + my_link + "\" target=\"_blank\">" + insText  + "</a>"+ input.value.substr(end);

 }

 return;

 }else{

 var my_link = prompt("Ingresar URL:","http://");

 var my_text = prompt("Ingresar el texto del link:","");

 input.value+=" <a href=\"" + my_link + "\" target=\"_blank\">" + my_text + "</a>";

 return;

 }
}
var reng=5;
function agregar(area){
	document.getElementById('quita').disabled=false;
	reng=reng+5;
	document.getElementById(area).rows=reng;
}
function quitar(area){
	reng=reng-5;
		if(reng<6){reng=5;
		}
	document.getElementById(area).rows=reng;
}
function ventana_emot(area){
	coordx=screen.width?(screen.width-300)/2:0;
	coordy=screen.height?(screen.height-150)/2:0;
	window.open("bbcode/emoticons/emoticons.html?campo="+area,"EMOTICONS","width=300,height=150,menubar=no,resizable=yes,left="+coordx+",top="+coordy);
}
function ins_imag(emot,area){
	var input = document.getElementById(area);
		if(typeof document.selection != 'undefined' && document.selection) {
			var str =document.selection.createRange().text;
			input.focus();
			var sel =document.selection.createRange();
			sel.text = str + emot;
			sel.select();
			return;
		}
		else if(typeof input.selectionStart != 'undefined'){
			var start = input.selectionStart;
			var end = input.selectionEnd;
			var insText = input.value.substring(start, end);
			input.value = input.value.substr(0, start) + insText+ emot + input.value.substr(end);
			input.focus();
			input.setSelectionRange(end+emot.length,end+emot.length);
			return;
		}
		else{
			input.value+=emot;
			return;
		}
}
function captura_imag(area){
	var my_link = prompt("Ingresar URL:","http://");
		if (my_link != null) {
			ins_imag('<img src=\"'+my_link+'\">',area);
		}
}
Incluyo ese archivo en la página <script src="BarraFormato.js"></script>
Luego esa barra se la puedes poner a cualquier <textarea> poniendo el nombre de esa caja en init('NombreCaja'), yo normalmente lo cargo poniéndolo en el onload del body y así ya carga la barra. Estoy haciendo una especie de panel de control y lo tengo todo en una página asp con varios select case
Código:
<%
Dim Modo
Modo=Ucase(Request.Querystring ("Mod"))
Select Case  Modo
	Case "C"
		Call Contra()
	Case "F"
		Call Formulario()
	Case "S"
		Call Subir()
	Case "A"
		Call Archivos()
	Case "M"	
		Call Modificar()
	Case "M2"	
		Call Modificar2()
	Case "RSS"
		Call RSS()
	Case "CON"
		Call Contador()
	Case Else
		Call Contra()
End select
%>
Esa función la uso sólo en el case RSS, si cargo cualquier otra pagina como no tiene el textarea txtNoticia me pone un error de carga en la barra de estado.¿¿o puedo poner un <body> para cada case??

Código:
<% Sub Contra %>
<body>
.
.
.
</body>
<% end Sub %>

<% Sub RSS %>
<body>
.
.
.
</body>
<% end Sub %>
Espero haberme explicado mejor, aunque creo que me lie un pco jejeje.

Saludos y gracias.
__________________
Huevos fritos con jamon, te los comes cuando quieras pero folla siempre con condón.