Click to See Complete Forum and Search --> : dynamic textfield?
digital_storm
11-04-2003, 01:56 PM
Hello!
I have a combobox with a couple of values, if value "studerar" is selected i want a textfield to be shown to the right of the combobox. Does anyone have a working example that you could share or give me a working syntax?
Thank you for helping me!
// Digitalstorm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Basic HTML</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
//<![CDATA[<!--
function AddInput(sname) {
if(sname=="studerar") {
var oInput = document.createElement('input');
oInput.setAttribute('name', sname);
oInput.setAttribute('type', 'text');
oInput.setAttribute('value', sname+' selected');
document.getElementById("div1").appendChild(oInput);
}
}
//-->//]]>
</script>
</head>
<body>
<form action="#" name="myform">
<div id="div1">
<select name="select1" onchange="AddInput(this.options[this.selectedIndex].text)">
<option value="a">apple</option>
<option value="b">banana</option>
<option value="c">cranberry</option>
<option value="s">studerar</option>
</select>
</div>
</form>
</body>
</html>