Click to See Complete Forum and Search --> : To place a text box at a specified position


sachin
03-09-2003, 09:12 PM
Hi,

I want to make a text box visible based on a select box values.Right now I am able to do that.but i want the text box to appear at position where the select box appears, it means to say that i want to replace the select box with text box in that position.

I have sample code

<html>
<head>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">

</head>
<body>
<form name="frm">
<select id="svalue" name="svalue" onchange="javascript:test();">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="other">other</option>
</select>
<input type="text" name="t1" style="visibility: hidden"/>
<br>
<br>





</form>
</body>
<script>

function test()
{

//alert(document.frm.svalue.options[document.frm.svalue.selectedIndex].value);
if (document.frm.svalue.options[document.frm.svalue.selectedIndex].value=="other")
{
document.frm.t1.style.visibility="visible";
}
else
{

document.frm.t1.style.visibility="hidden";


}



}



</script>

</html>

pyro
03-09-2003, 09:24 PM
Here is how I would do that...

<html>
<head>
<title></title>
<script language="javascript" type="text/javascript">
function test()
{
if (document.frm.svalue.options[document.frm.svalue.selectedIndex].value=="other")
{
document.frm.t1.style.display="block";
document.frm.svalue.style.display="none";
}
}
</script>

</head>
<body>
<form name="frm">
<select id="svalue" name="svalue" onchange="test();">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="other">other</option>
</select>
<input type="text" name="t1" style="display:none"/>
<br>
<br>
</form>
</body>
</html>