Jump to content
Fórum Script Brasil
  • 0

Ajuda com <form>


Matheus Britto
 Share

Question

Turma

Tenho um <form> e dentro dele uma lista com alguma opções, que quando selecionada, o resultado é mostrado dentro do <form> com o comando <input type="text" id="Selected">. Tem como esse resultado ser apresentado fora desse <form>, como texto simples?

Abaixo está o código para que possam analisar melhor (o script veio junto com o form, então nem toquei nele).

&lt;script type="text/javascript">

function Service() {

var list = document.getElementById("List");

document.getElementById("Selected").value = list.options[list.selectedIndex].value;

}

</script>

<form>

Select your service:

<select id="List" onChange="Service()">

<option></option>

<option value="GC">Google Chrome</option>

<option value="FF">Firefox</option>

<option value="IE">Internet Explorer</option>

<option value="S">Safari</option>

<option value="O">Opera</option>

</select>

<input type="text" id="Selected" size="2" /></p>

</form>

Alguém se habilita nessa ajuda?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

E ai beleza.

Acho que é isso.

<html>
<head>
<script>
function Service() {
var list = document.getElementById("List");
document.getElementById("texto").innerHTML = list.options[list.selectedIndex].value;
}

</script>
</head>
<body>
<form>
Select your service:
<select id="List" onChange="Service()">
<option></option>
<option value="GC">Google Chrome</option>
<option value="FF">Firefox</option>
<option value="IE">Internet Explorer</option>
<option value="S">Safari</option>
<option value="O">Opera</option>
</select>
<input type="text" id="Selected" size="2" /></p>
</form>
<p>
<span id="texto"></span>
</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
      150.9k
    • Total Posts
      648.8k
×
×
  • Create New...