Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


add and remove textbox on button click



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
user_123



Joined: 30 Jun 2008
Posts: 1

PostPosted: Mon Jun 30, 2008 1:52 pm    Post subject: add and remove textbox on button click Reply with quote

Hi all,
I want to add or remove textbox on button click and i am succeded in doing that....but the only problem is whenever i click on add or remove button the textbox get added/removed on new page instead on the same page....so how can i do that thing so that on bttn click it gets added on same page..here is my code............


<html>
<head>
<script language="javascript" type="text/javascript">

function incrementCount()
{
document.frm.txt.value=parseInt(document.frm.txt.value) + 1;
addtxtBox();
}

function decCount()
{
document.frm.txt.value=parseInt(document.frm.txt.value) - 1;
addtxtBox();
}


function addtxtBox()
{
//var count=10;
var b="";
var a=document.frm.txt.value;

for(var i=1;i<=a;i++)
{
document.write('<table width="40%">');
document.write('<tr><td>Name :</td>');
document.write('<td><input type="text" name="txt"></td></tr>');
document.write('</table>');


}

</script>

<body>

<table width="40%" border="1">
<form name="frm">
<tr>
<td>Name:</td>
<td><input type="text" name="txt" value="0" readonly ></td>
<!-- <td><textarea name="msg" id="message" rows="5" cols="40"></td>-->
<td><INPUT type="button" value="ADD" name="add" onClick="incrementCount()"></td>
<td><INPUT type="button" value="Remove" name="remove" onClick="decCount()"></td>
<!--<td><INPUT type="button" value="ADD" name="add" onClick="document.frm.txt.value=parseInt(document.frm.txt.value) + 1"></td>-->
<!-- <td><INPUT type="button" value="ADD" name="add" onClick="addtxtBox()"></td>-->
</tr>



</table>

</form>
</body>
</html>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap