Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2007
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sticky textboxes with Javascript

    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.

  • #2
    Regular Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    223
    Thanks
    0
    Thanked 14 Times in 14 Posts
    This sounds similar to this post that I answered the other day, does this help?

  • #3
    New to the CF scene
    Join Date
    Nov 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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" >


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •