Jump to content


Photo

Mostrar Div Ao Escolher Determinada Opcao No Select


  • Faça o login para participar
4 replies to this topic

#1 Layout WebHost

Layout WebHost

    Normal

  • Usuários
  • 95 posts
  • Sexo:Não informado

Posted 22/02/2007, 14:09

Pessoal, tenho o seguinte codigo que uso para exibir uma celular da tabela que esta oculta:

<script>
function opcoes( sId ) {
var sDiv = document.getElementById( sId );
if( sDiv.style.display == "none" ) {
sDiv.style.display = "table-cell";
}
}

</script>

onclick="opcoes('tipo_pagamento');"

		  <tr id="tipo_pagamento" style="display: none;">
			<td width="151" height="0" align="left" class="texto_4a" style="padding-left:5px">Carteira:</td>
			<td height="11"><input name="carteira" type="text" class="input" id="carteira" size="40" /></td>
		  </tr>

Atualmente funciona se eu colocar em um link ou checkbox e tals, porem preciso do seguinte, tenho o select:

<select name="tipo_pagamento" class="input" id="tipo_pagamento" style="width:254px;">
			  <option selected="selected" value="">Selecione um tipo</option>
			  <option value="deposito">Dep&oacute;sito/Transfer&ecirc;ncia</option>
			  <option value="boleto.bb.php">Boleto Banco do Brasil</option>
			  <option value="boleto.cef.php">Boleto Caixa E. Federal</option>
			  <option value="boleto.itau.php">Boleto Ita&uacute;</option>
			  <option value="boleto.hsbc.php">Boleto HSBC</option>
									</select>

E queria que quando uma das opcoes que tem "boleto" la fosse selecionada ele exibisse a celular, seria tipo assim(se funcionasse claro :P):

<option value="boleto.hsbc.php" onclick="opcoes('tipo_pagamento');">Boleto HSBC</option>

é possivel fazer isso?

#2 Klaus

Klaus

    @ ubuntu jaunty

  • Ex-Admins
  • 7924 posts
  • Sexo:Masculino
  • Localidade:127.0.0.1

Posted 22/02/2007, 15:04

<select onchange="check_payment( this.value );">
  options aqui
</select>

E o JS:

var check_payment = function( value )
{
  if( this.value.indexOf( "boleto" ) != -1 )
  {
	// aqui você exibe o que quiser, a opção atual é de boleto
  }
  else
  {
	// aqui você esconde, não é um boleto
  }
}

Klaus Paiva
Conheça também: Taperás

#3 Layout WebHost

Layout WebHost

    Normal

  • Usuários
  • 95 posts
  • Sexo:Não informado

Posted 22/02/2007, 15:23

fiz assim:

<script>

var checar_opcao = function( value )
{
  if( this.value.indexOf( "boleto" ) != -1 )
  {
function opcoes( 'tipo_pagamento' ) {
var sDiv = document.getElementById( 'tipo_pagamento' );
if( sDiv.style.display == "none" ) {
sDiv.style.display = "table-cell";
}
}
  }
  else
  {

  }
}
</script>

Mas nao funcionou, ele diz isso:
Erro: this.value has no properties
Linha 15: if( this.value.indexOf( "boleto" ) != -1 )

Edição feita por: Layout WebHost, 22/02/2007, 15:24.


#4 matt.cavotta

matt.cavotta

    Ativo

  • Usuários
  • 347 posts
  • Sexo:Masculino
  • Localidade:Campinas
  • Interesses:Desenvolvimento Web &amp; Programação

Posted 22/02/2007, 16:15

Olá, comentários no código

fiz assim:

<script>

var checar_opcao = function( value ) <-- esse já é o this.value
{
  if( value.indexOf( "boleto" ) != -1 ) <-- muda essa linha e vê o que dá
  {
function opcoes( 'tipo_pagamento' ) {
var sDiv = document.getElementById( 'tipo_pagamento' );
if( sDiv.style.display == "none" ) {
sDiv.style.display = "table-cell";
}
}
  }
  else
  {

  }
}
</script>

Mas nao funcionou, ele diz isso:
Erro: this.value has no properties
Linha 15: if( this.value.indexOf( "boleto" ) != -1 )


WebFórum - Equipe de Desenvolvimento - Estagiario

I'm back!
Posted Image Edgy Eft 7.04

#5 Layout WebHost

Layout WebHost

    Normal

  • Usuários
  • 95 posts
  • Sexo:Não informado

Posted 22/02/2007, 16:55

nao funcionou ainda, diz que checar_opcoes nao esta definido alem de outro erro "missing formal parameter"




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq