Jump to content
Fórum Script Brasil
  • 0

Mudar Type Em Um Form


cossalter
 Share

Question

Bom dia, pessoal.

Estou com o seguinte problema e gostaria de saber se tem solução.

Tenho um formulário com o seguinte código

...

<input name="localizacao" type="text">

<select name="tipo_loc">

<option value="0">CD</option>

<option value="1">Rede</option>

</select>

...

A parte do código de tabela foi omitida.

Gostaria que quando a pessoa selecionasse a opção Rede (1), o type de localizacao mudasse para file. E vice-versa.

Como poderia fazer isso?

Abraço!

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

exemplo ae:

<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
function muda(opc){
    if(opc == 'file'){
        str = '<input type="file" name="fl1" />';
    }else{
        str = '<input type="text" name="txt1" />';
    }
    document.getElementById('campo').innerHTML = str;
}
//-->
</script>

</head>
<body>
<select name="sl1" onchange="java script:muda(this.options[selectedIndex].value);">
<option value="">Escolha...</option>
<option value="file">File</option>
<option value="text">Text</option>
</select>
<div id="campo">
<input type="text" name="txt1" />
</div>
</body>
</html>

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.

 Share

  • Forum Statistics

    • Total Topics
      149.8k
    • Total Posts
      646.6k
×
×
  • Create New...