Jump to content


Wilk

Member Since 11/07/2005
Offline Last Active 17/11/2008, 18:00
-----

Topics I've Started

Menu Com Abas Que Muda O Iframe / Jquery!

15/11/2008, 16:20

Fala pessoal, estou com um problema aqui... o script não funciona no Opera, nem no Chrome.

É um script que muda o link do iframe pelas abas, sem carregar a página, só muda o iframe. O Funcionamento dele pode ser visto aqui: www.soldat.com.br

Segue o código:

function changetab(tabid) {
	//1=noticias, 2=agenda, 3=oracoes
	var targetpage = "";
	switch(tabid) {
		case 1:
			//document.getElementById('tabbox').src = "tabbox_noticias.php";
			targetpage = 'tabbox_noticias.php';
			break;
		case 2:
			//document.getElementById('tabbox').src = "tabbox_agenda.php";
			targetpage = 'tabbox_agenda.php';
			break;
		case 3:
			//document.getElementById('tabbox').src = "tabbox_oracoes.php";
			targetpage = 'tabbox_oracoes.php';
			break;
	}
	obj = findObj("tabbox");
	var ua = navigator.userAgent;
	if (ua.indexOf('MSIE') == -1) {
		obj.src = targetpage;
	} else {
		obj.location.href = targetpage;
	}

	//muda estilos das tabs
	var i;
	for (i=1; i<4; i++) {
	obj = findObj("tab_"+i);
		if (tabid == i) {
			//document.getElementById("tab_"+i).className = "active";
			obj.className = 'active';
		} else {
			//document.getElementById("tab_"+i).className = "";
			obj.className = '';
		}
	}
}

// Example: obj = findObj("image1");

function findObj(theObj, theDoc)

{

  var p, i, foundObj;

  

  if(!theDoc) theDoc = document;

  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)

  {

	theDoc = parent.frames[theObj.substring(p+1)].document;

	theObj = theObj.substring(0,p);

  }

  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];

  for (i=0; !foundObj && i < theDoc.forms.length; i++) 

	foundObj = theDoc.forms[i][theObj];

  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 

	foundObj = findObj(theObj,theDoc.layers[i].document);

  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

  

  return foundObj;

}


Acho que o erro está aqui:

var ua = navigator.userAgent;
if (ua.indexOf('MSIE') == -1) {
obj.src = targetpage;
} else {
obj.location.href = targetpage;
}

Mas não sei como resolve o problema... Será que por JQuery fica melhor?

Obrigado.

Dúvida Básica Em Array

22/10/2008, 17:07

Ae pessoal...

Tem alguma função ou alguma forma de comparar o valor de uma variável com um resultado de um array?

Tipo assim:

Array $letras (

[0] => abc
[1] => def
[2] => ghi

)

$a = abc;

if ($a == (nesse ponto que é a dúvida) $letras) {

echo "verdadeiro"

}

Entenderam? =O

É pq eu sei fazer isso fazendo um loop, mas to achando que usar um loop vai ser meio gambiarra.

Dúvida Básica

17/10/2008, 13:52

Pessoal, tenho um título de uma notícia no banco de dados SQL.

Se eu puxar a notícia com mysql_fetch_array... e der "echo $campo['titulo'];" ela vem certinha...


Mas acontece que fiz esse tratamento no título:

if (strlen($campo['titulo']) <= 48) {

echo $campo['titulo'] . "</a><br />";

}else{

$titulo = substr($campo['titulo'], 0, 45);

echo stripslashes($titulo) . "...</a><br />";

}

O segundo "echo" imprime o título assim:

"Minist&eacute;rio De Miss&otilde;es Na ICE Betel" Com esses & no lugar dos acentos. Estranho, pois se eu der $campo['titulo'], ela é impressa certinha o.o

Mysql, Dúvida Básica...

09/10/2008, 18:31

Pq quando faço um loop usando mysql_fetch_array($query); não posso usar isso de novo?

Exemplo:

<?
$resultado = mysql_query("SELECT * FROM  `tabela` ORDER BY `data`") or die ("Erro no Banco de Dados");

while ($campo = mysql_fecth_array($resultado)) {

comandos....

}

HTML

//Essa parte de baixo não funciona... PQ?

while ($camp2 = mysql_fecth_array($resultado)){

comandos...

} 

 ?>

Como faço? Tenho que fazer outra query? É uma dúvida básica, mas tá me matando.

Dúvida Em Loop

08/10/2008, 15:35

Estou num loop básico pra pegar os resultados do banco de dados, com mysql_fetch_array.

Acontece que várias linhas têm o $campo['ano'] com o mesmo valor.

Exemplo

Ano

2008
2008
2008
2008


Eu quero que: se o $campo['ano'] for igual a algum $campo['ano'] anterior já impresso, ele não seja impresso repetidamente.

Acho que é uma dúvida meio básica, mas tá complicado...

Agradecido, desde já.

IPB Skin By Virteq