Ir para conteúdo

POWERED BY:

Arquivado

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

Lethícia

Mudança de seleção para radio button

Recommended Posts

Estou com um problema para modificar a seleção para radio button!!!

 

Estou fazendo um sitema de busca em JavaScript, e funciona perfeitamente se eu coloco as URL's base em caixa de seleção, mais se mudo para radio button não funciona, alguém poderia me dar uma ajuda?

 

Também não consegui fazer o link ir direto a página simplesmente apertando o botão "ENTER" do teclado.

 

Vou postar os dois códigos

 

Codigo Correto "Que sempre funciona";

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<script language="javascript">

 

function Buscar(frm, tipo, query) {

with (frm) {

str = tipo.options[tipo.selectedIndex].value;

str += query.value;

url = str;

top.location.href = url;

}

}

</script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Untitled Document</title>

<link href="css/style.css" type=text/css rel=stylesheet>

</head>

 

<body>

<form action="java script:Buscar();" method="post">

<table width="373" border="0" cellpadding="0" cellspacing="0" background="imgs/barra_1.jpg">

<tr>

<td width="320"><table width="320" border="0" cellspacing="0" cellpadding="0">

<tr>

<td><select name="tipo" class="inputText">

<option selected value="http://sites/music/busca_artista.html?query=">Artista</option>

<option value="http://sites/music/busca_video.html?query=">Video</option>

</select></td>

</tr>

<tr>

<td><input type="text" name="query" class="inputText"></td>

</tr>

</table></td>

<td width="53"><table width="53" border="0" cellspacing="0" cellpadding="0"><tr>

<td width="53"><img src="imgs/barra_2.jpg" width="53" height="15"></td>

</tr>

<tr>

<td width="53"><table width="53" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="38"><input name="submit" type="image" onclick="Buscar(this.form, this.form.tipo, this.form.query)" value="Buscar" src="imgs/barra_3_botao.jpg" width="38" height="37"></td>

<td width="15"><img src="imgs/barra_4.jpg" width="15" height="37"></td>

</tr>

</table></td>

</tr>

<tr>

<td width="53"><img src="imgs/barra_5.jpg" width="53" height="28"></td>

</tr>

</table></td>

</tr>

</table></form>

</body>

</html>

 

Abaixo o código que não dá certo;

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<script language="javascript">

 

function Buscar(frm, tipo, query) {

with (frm) {

str = tipo.options[tipo.selectedIndex].value;

str += query.value;

url = str;

top.location.href = url;

}

}

</script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Untitled Document</title>

<link href="css/style.css" type=text/css rel=stylesheet>

</head>

 

<body>

<form action="java script:Buscar();" method="post">

<table width="373" border="0" cellpadding="0" cellspacing="0" background="imgs/barra_1.jpg">

<tr>

<td width="320"><table width="320" border="0" cellspacing="0" cellpadding="0">

<tr>

<td><table width="320" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="25"><label>

<input name="tipo" type="radio" value="http://sites/music/busca_artista.html?query=" checked>

</label></td>

<td width="50">Artista</td>

<td width="25"><label>

<input name="tipo" type="radio" value="http://sites/music/busca_video.html?query=">

</label></td>

<td width="220">Video</td>

</tr>

</table></td>

</tr>

<tr>

<td><input type="text" name="query" class="inputText"></td>

</tr>

</table></td>

<td width="53"><table width="53" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="53"><img src="imgs/barra_2.jpg" width="53" height="15"></td>

</tr>

<tr>

<td width="53"><table width="53" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="38"><input name="submit" type="image" onclick="Buscar(this.form, this.form.tipo, this.form.query)" value="Buscar" src="imgs/barra_3_botao.jpg" width="38" height="37"></td>

<td width="15"><img src="imgs/barra_4.jpg" width="15" height="37"></td>

</tr>

</table></td>

</tr>

<tr>

<td width="53"><img src="imgs/barra_5.jpg" width="53" height="28"></td>

</tr>

</table></td>

</tr>

</table>

</form>

</body>

</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

tente assim:

function Buscar(frm, tipo, query) {  with (frm) {	str = tipo.value;	str += query.value;	url = str;	top.location.href = url;  }}

F.

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.