Why does n't I get the selected value ?

J

Jean Passe

Hi,

The following does not work (I get nothing in the input box) :

<html>
<head>
<script type="text/javascript" language=javascript">

function afficher()
{
var idselection=window.document.truc.ma_combo;
var indexselection=idselection.selectedIndex;
var selectionenclair =idselection.options[indexselection].value;
window.document.truc.sel.value=selectionenclair;

}

</script>
</head>
<body>
<form name="truc">
<select name="ma_combo" size=1>
<option value="one" selected>one
<option value="two">two
<option value="three">three
</select>
<br>
<input type="text" name="sel" value="" size=10>
<br>
<input type="button" value="Afficher" onClick="afficher(" ")">
</form>
</body>
</html>

Why ????

Thanks.
 
L

Lee

Jean Passe said:
Hi,

The following does not work (I get nothing in the input box) :

<html>
<head>
<script type="text/javascript" language=javascript">

You're missing a quote in the line above, and have two extra
quotes in the line below:
<input type="button" value="Afficher" onClick="afficher(" ")">

onclick="afficher()"

You cannot nest quotes within quotes in HTML.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top