Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

ronaldo_calado

Linka para uma div

Recommended Posts

Tem... combinando PHP com Ajax

Compartilhar este post


Link para o post
Compartilhar em outros sites

tem sim, mas não tem nada a ver com PHP.você vai usar HTML + Javascript.;)

Eu discordo com o seu comentário, pra mim tem a ver com PHP sim... pois como é uma notícia e é dinâmica, e esse dinamico se faz com PHP... o serto seria HTML + PHP + AJAX os tres juntos...Soh uma coisa, naum to brigando naum viu.. soh dando a minha opnião sobre o seu comentário

Compartilhar este post


Link para o post
Compartilhar em outros sites

wolfphw tem razão...tem a ver sim...não é a toa que existe inclusive frameworks como o SAJAX =Dmas pro cara que postou o tópico:dá uma olhada no fórum de ajax, lá tem a solução pro que você precisa, tem uns códigos muito bons do micox...abraço!

Compartilhar este post


Link para o post
Compartilhar em outros sites

 

tem sim, mas não tem nada a ver com PHP.

 

você vai usar HTML + Javascript.

;)

Eu discordo com o seu comentário, pra mim tem a ver com PHP sim... pois como é uma notícia e é dinâmica, e esse dinamico se faz com PHP... o serto seria HTML + PHP + AJAX os tres juntos...

 

Soh uma coisa, naum to brigando naum viu.. soh dando a minha opnião sobre o seu comentário

 

hehehe, sem stress ;)

 

 

ronaldo_calado

segue um exemplo simples do que falei:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><script type="text/javascript">function mostraNoticia(codigo){	//pega a div	var div = document.getElementById("noticia"+codigo);		//mostra a noticia	if(div.style.display == "none"){		div.style.display="block";	}else{		div.style.display="none";	}}</script></head><body><div>- <a href="#" onclick="mostraNoticia('01');">noticia 01</a></div><div id="noticia01" style="display:none;">texto da noticia 01, texto da noticia 01, texto da noticia 01</div></body></html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Valew Samuel, o script funciono bacana http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gifSó mais uma coisa, como eu faria pra alterar o posicionamento dessa DIV ??? :mellow:

como assim?aonde você quer colocar ela?me de um exemplo aí, para que eu possa ajudar ;)

Compartilhar este post


Link para o post
Compartilhar em outros sites

como assim?

aonde você quer colocar ela?

 

me de um exemplo aí, para que eu possa ajudar ;)

É que ela está aparecendo embaixo do link, se eu quisesse posicioná-la mais ou centro, fazer com que ela abra em outro lugar, tipo left:200px, top: 15px

Entendeu?? http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif

Compartilhar este post


Link para o post
Compartilhar em outros sites

Fiz oq eu qria em html, funcionou bem, quem quiser dar uma olhada no código vou colocar embaixo, mais tem um probleminha, gostaria de fazer com que tudo fosse dinamico, que desse a lista de noticias e que quando clicasse no link, abriria a div, só que quando eu coloco em php ta dando problema no link que chama a div.

se eu coloco assim: echo "<a href=\"?imovel=$id\" onclick=\"MM_showHideLayers('showimage','', 'show')\">$bairro1</a><br>";

 

a div abre e fecha rapidamente, da só uma piscada na tela, e se eu coloco assim:

echo "<a href=\"http://?imovel=$id\" onclick=\"MM_showHideLayers('showimage','', 'show')\">$bairro1</a><br>";

a div abre direito mais não passa os valores das variaveis para a div, da pra alguem me ajudar a fazer isso??? http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif

 

Os códigos

HTML

</html>

<head>

<script language=JavaScript>

<!--

var dragswitch=0

var nsx

var nsy

var nstemp

function drag_dropns(name){

temp=eval(name)

temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)

temp.onmousedown=gons

temp.onmousemove=dragns

temp.onmouseup=stopns

}

function gons(e){

temp.captureEvents(Event.MOUSEMOVE)

nsx=e.x

nsy=e.y

}

function dragns(e){

if (dragswitch==1){

temp.moveBy(e.x-nsx,e.y-nsy)

return false

}

}

function stopns(){

temp.releaseEvents(Event.MOUSEMOVE)

}

var dragapproved=false

function drag_dropie(){

if (dragapproved==true){

document.all.showimage.style.pixelLeft=tempx+event.clientX-iex

document.all.showimage.style.pixelTop=tempy+event.clientY-iey

return false

}

}

function initializedragie(){

iex=event.clientX

iey=event.clientY

tempx=showimage.style.pixelLeft

tempy=showimage.style.pixelTop

dragapproved=true

document.onmousemove=drag_dropie

}

if (document.all){

document.onmouseup=new Function("dragapproved=false")

}

function hidebox(){

if (document.all)

showimage.style.visibility="hidden"

else if (document.layers)

document.showimage.visibility="hide"

}

 

function MM_findObj(n, d) { //v4.01

var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];

for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);

if(!x && d.getElementById) x=d.getElementById(n); return x;

}

 

function MM_showHideLayers() { //v6.0

var i,p,v,obj,args=MM_showHideLayers.arguments;

for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args))!=null) { v=args[i+2];

if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }

obj.visibility=v; }

}

//-->

</SCRIPT>

<style type="text/css">

<!--

.style1 {

color: #000000;

font-weight: bold;

}

#Layer1 {

position:absolute;

left:212px;

top:51px;

width:250;

height:250;

z-index:1;

}

-->

</style>

<script type="text/javascript">

<!--

function MM_reloadPage(init) { //reloads the window if Nav4 resized

if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}

MM_reloadPage(true);

//-->

</script>

</head>

 

<body>

<div id=showimage style="LEFT: 300; POSITION: absolute; TOP: 1px; WIDTH: 147px; visibility: hidden;">

<table width="250" height="153" border="0" cellpadding="0" cellspacing="0">

<tr bgcolor="#ff0088">

<TD onmousedown=initializedragie() style="CURSOR: hand"

width="100%"><ILAYER width="100%"><LAYER onmouseout=dragswitch=0

onmouseover=dragswitch=1;drag_dropns(showimage) width="100%"><FONT

color=#ffffff face=Verdana><STRONG><SMALL>Caixa de aviso</SMALL></STRONG></FONT></LAYER></ILAYER></TD>

<TD style="CURSOR: hand"><A

href="http://"

onclick="hidebox();return false">X</A></TD>

</tr>

<tr>

<td height="240" colspan="2" valign="top" bgcolor="#CCCCCC">ascascasklnckajsncn</td>

</tr>

</table>

</div>

<a href="http://" target="centro" onClick="MM_showHideLayers('showimage','','show')">Notícia 1 </a>

</body>

</html>

PHP

<html>

<head>

<script language=JavaScript>

<!--

var dragswitch=0

var nsx

var nsy

var nstemp

function drag_dropns(name){

temp=eval(name)

temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)

temp.onmousedown=gons

temp.onmousemove=dragns

temp.onmouseup=stopns

}

function gons(e){

temp.captureEvents(Event.MOUSEMOVE)

nsx=e.x

nsy=e.y

}

function dragns(e){

if (dragswitch==1){

temp.moveBy(e.x-nsx,e.y-nsy)

return false

}

}

function stopns(){

temp.releaseEvents(Event.MOUSEMOVE)

}

var dragapproved=false

function drag_dropie(){

if (dragapproved==true){

document.all.showimage.style.pixelLeft=tempx+event.clientX-iex

document.all.showimage.style.pixelTop=tempy+event.clientY-iey

return false

}

}

function initializedragie(){

iex=event.clientX

iey=event.clientY

tempx=showimage.style.pixelLeft

tempy=showimage.style.pixelTop

dragapproved=true

document.onmousemove=drag_dropie

}

if (document.all){

document.onmouseup=new Function("dragapproved=false")

}

function hidebox(){

if (document.all)

showimage.style.visibility="hidden"

else if (document.layers)

document.showimage.visibility="hide"

}

 

function MM_findObj(n, d) { //v4.01

var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];

for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);

if(!x && d.getElementById) x=d.getElementById(n); return x;

}

 

function MM_showHideLayers() { //v6.0

var i,p,v,obj,args=MM_showHideLayers.arguments;

for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args))!=null) { v=args[i+2];

if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }

obj.visibility=v; }

}

//-->

</SCRIPT>

<style type="text/css">

<!--

.style1 {

color: #000000;

font-weight: bold;

}

#Layer1 {

position:absolute;

left:212px;

top:51px;

width:250;

height:250;

z-index:1;

}

-->

</style>

<script type="text/javascript">

<!--

function MM_reloadPage(init) { //reloads the window if Nav4 resized

if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}

MM_reloadPage(true);

//-->

</script>

</head>

 

<?

 

$conecta = mysql_connect("localhost","root","");

mysql_select_db("rd");

 

?>

 

<body>

 

<?

 

$comando = mysql_query("select * from bairros");

$resul = 4;

 

for($i=1;$i<=$resul;$i++)

{

$array = mysql_fetch_array($comando);

$id = $array['id_bairro'];

$bairro1 = $array['bairro'];

 

echo "<a href=\"?imovel=$id\" onclick=\"MM_showHideLayers('showimage','', 'show')\">$bairro1</a><br>";

}

 

?>

 

<div id=showimage style="LEFT: 300; POSITION: absolute; TOP: 1px; WIDTH: 147px; visibility: hidden;">

<table width="250" height="153" border="0" cellpadding="0" cellspacing="0">

<tr bgcolor="#ff0088">

<TD colspan="3" align="left" style="CURSOR: hand" onmousedown=initializedragie()>  <ILAYER width="84" height="23"><LAYER left="5" width="77" height="18"

onmouseover=dragswitch=1;drag_dropns(showimage) onmouseout=dragswitch=0><FONT

color=#ffffff face=Verdana><STRONG><SMALL>Bairros</SMALL></STRONG></FONT></LAYER>

</ILAYER>

                                           <A

href="http://"

onclick="hidebox();return false">X</A></TD>

</tr>

<tr>

 

<?

 

@$id_imovel = $_GET['imovel'];

 

echo $id_imovel;

 

$comando2 = mysql_query("select * from imoveis where id_imovel='$id_imovel'");

$array2 = mysql_fetch_array($comando2);

 

$bairro12 = $array2['bairro'];

$tipo2 = $array2['tipo_imovel'];

$transacao2 = $array2['transacao'];

 

?>

 

<td width="5" height="240" valign="top" bgcolor="#CCCCCC"> </td>

<td width="240" valign="top" bgcolor="#CCCCCC"><? echo $bairro12.'<br>'.$tipo2.'<br>'.$transacao2; ?></td>

<td width="5" height="240" valign="top" bgcolor="#CCCCCC"> </td>

</tr>

</table>

</div>

</body>

</html>

Valew galera, espero a ajuda de alguem!! ;)

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.