View Full Version : how to replace listbox by text box dynamically

10-19-2008, 09:00 PM
When I click Button in html page, the list box should be replaced by text box.
How to do this by using Javascript. Please help me

10-20-2008, 12:55 AM
Will this work for you?

<title>Listbox - Textbox swap</title>
<script type="text/javascript">
function Swapper() {
var elem = document.getElementById('dLbox');
if (elem.style.display == 'block') {
elem.style.display = 'none';
document.getElementById('dTbox').style.display = 'block';
} else {
elem.style.display = 'block';
document.getElementById('dTbox').style.display = 'none';
<h1> Listbox - Textbox swap</h1>
<div id="dLbox" style="display:block">
<select id="Lbox">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<div id="dTbox" style="display:none">
<input type="text" id="Tbox" value="">
<button onclick="Swapper()">Swap</button>

10-20-2008, 12:46 PM
I have fields

Categories Listbox
Product Textbox
I have two buttons submit,Save
when I click this Save this Listbox should be replaced by textbox
Please help me how to change.

10-20-2008, 01:48 PM
Thank You for your help