Jump to content


Javascript with PHP

  • Please log in to reply
1 reply to this topic

#1 vidyashankara

  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 20 July 2006 - 03:40 PM

I have this function on my php script..

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;

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?

#2 nogray

  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 20 July 2006 - 04:54 PM

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
var div = document.createElement("DIV");

replace this
document.getElementById('prot').innerHTML += txt;

div.innerHTML = txt;

Let me know if this works


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users