Nicky Antunes Posted April 11, 2012 Report Share Posted April 11, 2012 Preciso alterar o Link "HAHAHA" com JavaScript, ao clicar nos botões. Veja o código abaixo:<script type="text/javascript"> var x=0; function rotate(num){ fs=document.ff.slide; x=num%fs.length; if(x<0) x=fs.length-1; document.images.show.src=fs.options[x].value; fs.selectedIndex=x;} </script> <script type="text/javascript"> var y=0; function rotate1(num){ fs=document.ff.slide; y=num%fs.length; if(y<0) y=fs.length-1; document.location.face.href=fs.option[y].value; fs.selectedIndex=y;} </script> <style type="text/css"> .style1 { border-collapse: collapse; border: 3px solid black; } .style2 { font-size: xx-small; } .style3 { text-align: right; } .style4 { text-align: center; } .style5 { text-align: left; } </style> <form name="ff"> <table cellpadding="3" class="style1"> <tbody class="style5"> <tr style="font-family: "Trebuchet MS",sans-serif;"><th align="center"><span style="font-size: x-large;">Troll Division - Tiras</span></th></tr> <tr style="font-family: "Trebuchet MS",sans-serif;"><td align="center"><img name="show" src="http://i1063.photobucket.com/albums/t511/troll_division/primeira.png" /> </td></tr> <tr style="font-family: "Trebuchet MS",sans-serif;"><td class="style5" style="border: 1px black solid;"><select name="slide" onchange="rotate(this.selectedIndex);rotate1(this.selectedIndex);"> <option value="http://i1063.photobucket.com/albums/t511/troll_division/primeira.png">Tira 1 - Introdução</option> <option value="http://i1063.photobucket.com/albums/t511/troll_division/gerusoesquisito.png">Tira 2 - Geruso</option> <option value="http://i1063.photobucket.com/albums/t511/troll_division/personagens.png">Tira 3 - Apresentando os 4 personagens</option> <option value="http://i1063.photobucket.com/albums/t511/troll_division/ursopolar.png">Tira 4 - Pro urso polar</option> </select> <<< Escolha a tira e <b> AGUARDE CARREGAR</b></td></tr> <tr style="font-family: "Trebuchet MS",sans-serif;"><td class="style4" style="border: 1px black solid;"><input id="button" onclick="rotate(0);rotate1(0);" title="Ver a primeira postada" type="button" value="<< Primeira" /> <input id="button" onclick="rotate(x-1);rotate1(x-1);" title="Anterior" type="button" value="< Anterior" /> <input id="button" onclick="rotate(x+1);rotate1(x+1);" title="Próxima" type="button" value="Próxima >" /> <input id="button" onclick="rotate(this.form.slide.length-1);rotate1(this.form.slide.length-1);" title="Ver a última postada" type="button" value="Última >>" /> <br /> </td></tr> <tr style="font-family: "Trebuchet MS",sans-serif;"><td class="style3" style="border: 1px black solid;"></td></tr> <a name="face" href="http://i1063.photobucket.com/albums/t511/troll_division/primeira.png">HAHAHA</a> </tbody></table> </form> Pois bem, quando clico nos botões, simplesmente não troca o "href" como deveria mudar. A idéia central é passar o link que está dentro do <option value="link"> para o <a name="face" href="link"> Quote Link to comment Share on other sites More sharing options...
0 Nicky Antunes Posted April 27, 2012 Author Report Share Posted April 27, 2012 UP...NINGUÉM? ¬¬ Quote Link to comment Share on other sites More sharing options...
0 Roger Mauricio Takemiya Posted April 27, 2012 Report Share Posted April 27, 2012 <script type="text/javascript"> var x=0; function rotate(num){ fs=document.ff.slide; x=num%fs.length; if(x<0) x=fs.length-1; document.images.show.src=fs.options[x].value; fs.selectedIndex=x;} </script> <script type="text/javascript"> var y=0; function g(id){ return document.getElementById(id); } function rotate1(num){ var el = g('slide'); var elDes = g('face'); var selEl = el.options[el.selectedIndex]; elDes.href = selEl.text; } </script> <style type="text/css"> .style1 { border-collapse: collapse; border: 3px solid black; } .style2 { font-size: xx-small; } .style3 { text-align: right; } .style4 { text-align: center; } .style5 { text-align: left; } </style> <form name="ff"> <table cellpadding="3" class="style1"> <tbody class="style5"> <tr style="font-family: "Trebuchet MS",sans-serif;"><th align="center"><span style="font-size: x-large;">Troll Division - Tiras</span></th></tr> <tr style="font-family: "Trebuchet MS",sans-serif;"><td align="center"><img name="show" src="http://i1063.photobucket.com/albums/t511/troll_division/primeira.png" /> </td></tr> <tr style="font-family: "Trebuchet MS",sans-serif;"><td class="style5" style="border: 1px black solid;"><select name="slide" id="slide" onchange="rotate(this.selectedIndex);rotate1(this.selectedIndex);"> <option value="http://i1063.photobucket.com/albums/t511/troll_division/primeira.png">Tira 1 - Introdução</option> <option value="http://i1063.photobucket.com/albums/t511/troll_division/gerusoesquisito.png">Tira 2 - Geruso</option> <option value="http://i1063.photobucket.com/albums/t511/troll_division/personagens.png">Tira 3 - Apresentando os 4 personagens</option> <option value="http://i1063.photobucket.com/albums/t511/troll_division/ursopolar.png">Tira 4 - Pro urso polar</option> </select> <<< Escolha a tira e <b> AGUARDE CARREGAR</b></td></tr> <tr style="font-family: "Trebuchet MS",sans-serif;"><td class="style4" style="border: 1px black solid;"><input id="button" onclick="rotate(0);rotate1(0);" title="Ver a primeira postada" type="button" value="<< Primeira" /> <input id="button" onclick="rotate(x-1);rotate1(x-1);" title="Anterior" type="button" value="< Anterior" /> <input id="button" onclick="rotate(x+1);rotate1(x+1);" title="Próxima" type="button" value="Próxima >" /> <input id="button" onclick="rotate(this.form.slide.length-1);rotate1(this.form.slide.length-1);" title="Ver a última postada" type="button" value="Última >>" /> <br /> </td></tr> <tr style="font-family: "Trebuchet MS",sans-serif;"><td class="style3" style="border: 1px black solid;"></td></tr> <a name="face" id="face" href="http://i1063.photobucket.com/albums/t511/troll_division/primeira.png">HAHAHA</a> </tbody></table> </form> Quote Link to comment Share on other sites More sharing options...
0 Nicky Antunes Posted May 3, 2012 Author Report Share Posted May 3, 2012 Mandei-lhe uma mensagem Roger. Quote Link to comment Share on other sites More sharing options...
0 fiote Posted May 4, 2012 Report Share Posted May 4, 2012 Nick, você deveria olhar no console de erros. O código está dando erro quando clica nos botões. Quote Link to comment Share on other sites More sharing options...
0 Nicky Antunes Posted May 4, 2012 Author Report Share Posted May 4, 2012 Desculpe se estou sendo chato, mas novamente volte aqui pedindo a ajuda de vocês.Resolvi colocar os comentários do facebook no pequeno leitor de fotos, usando a mesma linha de raciocínio aqui já aplicada.<title>Leitor de tiras do Troll Division</title> <script type="text/javascript"> var y=0; function g(id){ return document.getElementById(id); } function rotate1(num){ var el = g('slide'); var elDes = g('face'); var selEl = el.options[el.selectedIndex]; elDes.href = selEl.text; } </script> <script type="text/javascript"> var x=0; function rotate(num){ fs=document.ff.slide; x=num%fs.length; if(x<0) x=fs.length-1; document.images.show.src=fs.options[x].value; fs.selectedIndex=x;} </script> <style type="text/css"> .style1 { border-collapse: collapse; border: 3px solid black; } .style2 { font-size: xx-small; } .style3 { text-align: right; } .style4 { text-align: center; } .style5 { text-align: left; } </style> <form name="ff"> <table cellpadding="3" class="style1"> <tbody class="style5"> <tr style="font-family: "Trebuchet MS",sans-serif;"><th align="center"><span style="font-size: x-large;">Troll Division - Tiras</span></th></tr> <tr style="font-family: "Trebuchet MS",sans-serif;"><td align="center"><img name="show" src="http://i1063.photobucket.com/albums/t511/troll_division/primeira.png" /> </td></tr> <tr style="font-family: "Trebuchet MS",sans-serif;"><td class="style5" style="border: 1px black solid;"><select name="slide" id="slide" onchange="rotate(this.selectedIndex);rotate1(this.selectedIndex);"> <option value="http://i1063.photobucket.com/albums/t511/troll_division/primeira.png">Tira 1 - Introdução</option> <option value="http://i1063.photobucket.com/albums/t511/troll_division/gerusoesquisito.png">Tira 2 - Geruso</option> <option value="http://i1063.photobucket.com/albums/t511/troll_division/personagens.png">Tira 3 - Apresentando os 4 personagens</option> </select> <<< Escolha a tira e <b> AGUARDE CARREGAR</b></td></tr> <tr style="font-family: "Trebuchet MS",sans-serif;"><td class="style4" style="border: 1px solid black;"><input id="button" onclick="rotate(0);rotate1(0);" title="Ver a primeira postada" type="button" value="<< Primeira" /> <input id="button" onclick="rotate(x-1);rotate1(x-1);" title="Anterior" type="button" value="< Anterior" /> <input id="button" onclick="rotate(x+1);rotate1(x+1);" title="Próxima" type="button" value="Próxima >" /> <input id="button" onclick="rotate(this.form.slide.length-1);rotate1(this.form.slide.length-1);" title="Ver a última postada" type="button" value="Última >>" /> <br /> <div id="fb-root"> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/pt_BR/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div id="face" class="fb-comments" href="http://www.trolldivision.com/p/Tira%201%20-%20Introdu%C3%A7%C3%A3o" data-num-posts="6" data-width="650"></div></div> </td></tr> <tr style="font-family: "Trebuchet MS",sans-serif;"><td class="style3" style="border: 1px solid black;"></td></tr> </tbody></table> </form>O problema é que não muda o "href", ou até muda, mas o div não atualiza automaticamente =/Eu não sei usar ajax, então... Gostaria da ajuda de vocês. Quote Link to comment Share on other sites More sharing options...
0 Nicky Antunes Posted May 11, 2012 Author Report Share Posted May 11, 2012 UP Quote Link to comment Share on other sites More sharing options...
0 Nicky Antunes Posted May 18, 2012 Author Report Share Posted May 18, 2012 Ninguém? =/ Quote Link to comment Share on other sites More sharing options...
Question
Nicky Antunes
Preciso alterar o Link "HAHAHA" com JavaScript, ao clicar nos botões. Veja o código abaixo:
Pois bem, quando clico nos botões, simplesmente não troca o "href" como deveria mudar. A idéia central é passar o link que está dentro do para oLink to comment
Share on other sites
7 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.