vidyashankara Posted July 20, 2006 Share Posted July 20, 2006 I have this function on my php script..[code]echo "function add() {var i =1;var txt = \"SEGID : <select name='segid[]'>";for ($i=0; $i<count($atm); $i++) {echo "<option value='PRO$atm[$i]'>PRO$atm[$i]";}echo "</select>\";txt +=\" Residue : <select name='resi[]'> <option value=ASP>ASP <option value=GLU>GLU <option value=LYS>LYS </select>\";txt +=\" Residue ID : <input type='text' name='resid[]' + i><br>\";document.getElementById('prot').innerHTML += txt;}";[/code]This function adds a set of text boxes everytime you click a button. The problem is, when you click on the button the second time, the values in the first set of text boxes gets reset and i gotta enter them again. is there anyway to prevent that? Quote Link to comment Share on other sites More sharing options...
nogray Posted July 20, 2006 Share Posted July 20, 2006 Hey there,I notice this problem happens in Firefox, so here is how you can fix it.add this to the top of the function[code]var div = document.createElement("DIV");[/code]replace thisdocument.getElementById('prot').innerHTML += txt;with[code]div.innerHTML = txt;document.getElementById('prot').appendChild(div);[/code]Let me know if this works Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.