...

View Full Version : Sticky textboxes with Javascript



rock_14
07-16-2007, 03:33 PM
I have series of Javascript textboxes created from a function like this:

<script language="javascript">


function changeItNew()
{
var i = 1;

my_div.innerHTML = my_div.innerHTML +"<br>"

my_div.innerHTML = my_div.innerHTML +"<tr><td>Block</td><td><input type='text' name='block'+ i></td></tr>"
my_div.innerHTML = my_div.innerHTML +"<tr><td>Section</td><td><input type='text' name='section'+ i></td></tr>"
my_div.innerHTML = my_div.innerHTML +"<tr><td>Survey</td><td><input type='text' name='survey'+ i></td></tr>"
my_div.innerHTML = my_div.innerHTML +"<tr><td>Abstract</td><td><input type='text' name='abstract'+ i></td></tr>"
my_div.innerHTML = my_div.innerHTML +"<tr><td>Lot</td><td><input type='text' name='lot'+ i></td></tr>"
my_div.innerHTML = my_div.innerHTML +"<tr><td>Township</td><td><input type='text' name='township'+ i></td></tr>"
my_div.innerHTML = my_div.innerHTML +"<tr><td>Range</td><td><input type='text' name='range'+ i></td></tr>"
my_div.innerHTML = my_div.innerHTML +"<br><input type='button' value='Add Additional Acre Details' onClick='changeItNew()'>"


}
</script>

And then in the form I have the following:

<tr><td>&nbsp;&nbsp;&nbsp;</td><td><input type="button" value="Add Acre Details" onClick="changeItNew()"><div id="my_div"></div></td></tr>

Every time the button is clicked, the values that were typed in from the previous area vanish. How can I make it where when the button is clicked to enter the next set of data, the previous values are retained?

Any ideas / suggestions would be greatly appreciated.

mcjwb
07-17-2007, 05:30 PM
This sounds similar to this post (http://www.codingforums.com/showthread.php?t=118641)that I answered the other day, does this help?

alpi
11-04-2007, 06:45 PM
Hi my code like this can anyone help me how can i get this dynamic textbox value in other asp page (Syntex) & how can i validate dynamic field.
Thanks in advance.

<script language="javascript">
function changeIt()
{

var checkStr = theForm.t1.value;
for (i = 0; i < checkStr; i++)
{
my_div.innerHTML = my_div.innerHTML +"<br><input type='text' name='mytext'+i>"

}

}
</script>

<form name="theForm" method="post" action="data.asp">
<input type="text" name=t1>
<input type="button" value="test" onClick="changeIt()">
<div id="my_div"></div>

<input type="image" border="0" name="submit" src="../images/submit.gif" width="65" height="23" >



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum