generation de textbox en fonction de selectbox
Bonjour,
J'essaye de generer un textbox dynamiquement quand je chosis une valeur du selectbox. Le code marche bien. Mon souci c'est la mise en page. Le plus je clique sur le selectbox, le plus d'ecart entre mon textbox et et le selectbox. J'arrive pas a comprendre pourquoi mes selectbox et textbox change d'endroit au clic du selectbox.
Voici le code complet:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
// <![CDATA[
function display(obj,id1,id2) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
if ( txt.match(id2) ) {
document.getElementById(id2).style.display = 'block';
}
}
// ]]>
</script>
</head>
<body>
<form>
<table>
<tr>
<td align="right" class="bodyfontwhite">Etat</td>
<td class="bodyfontwhite">
<select name="etat" onChange="display(this,'Occasion','Neuve');">
<option value = 'Occasion'>Occasion</option>
<option value = 'Neuve'>Neuve</option>
</select>
</td>
</tr>
<tbody align="right" id="Occasion">
<tr>
<td align="right" class="bodyfontwhite">Kilometrage</td>
<td class="bodyfontwhite"><input type="text" name="kilometrage" value=""/></td>
</tr>
</tbody>
<tbody align="right" id="Neuve"></tbody>
</table>
</form>
</body>
</html> |