Jump to content
Fórum Script Brasil
  • 0

Ajuda com o código


Nicky Antunes

Question

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>
&lt;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">

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0
<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>

Link to comment
Share on other sites

  • 0

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>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</select>
&lt;&lt;&lt; Escolha a tira e <b> AGUARDE CARREGAR</b></td></tr>
<tr style="font-family: &quot;Trebuchet MS&quot;,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="&lt;&lt; Primeira" />
<input id="button" onclick="rotate(x-1);rotate1(x-1);" title="Anterior" type="button" value="&lt; Anterior" />&nbsp;
<input id="button" onclick="rotate(x+1);rotate1(x+1);" title="Próxima" type="button" value="Próxima &gt;" />
<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 &gt;&gt;" />
<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: &quot;Trebuchet MS&quot;,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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...