HTML Element
If your a member of codenstuff then this is the main place to be. Get together..talk..chat and ponder. Have fun. Chill out. Play games.
7 posts
Page 1 of 1
Hello Coders
I need help with html, i'm trying to add an element to a form.
So basically i got a textbox and i got a button under it thats says "add more" and onclick i want it to add a new textbox above the button, under the textbox.
+rep for best answer
Thanks
CodexVideos
I need help with html, i'm trying to add an element to a form.
So basically i got a textbox and i got a button under it thats says "add more" and onclick i want it to add a new textbox above the button, under the textbox.
+rep for best answer
Thanks
CodexVideos
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
Is this what you are after?
Code: Select all
<script type="text/javascript">
function clicked()
{
var container = document.getElementById("container");
container.innerHTML += '<input type="text" /> ';
container.innerHTML += "<div> </div>";
}
</script>
<body>
<span id="container"></span>
<input type="button" value="Add more" onclick="clicked()" />
</body>
Last edited by mandai on Sun Nov 07, 2010 5:24 pm, edited 1 time in total.
no mandai, i already have that code, but then it adds unlimited textbox's, i want to limit it.
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
You could add a counter for the number of times clicked if you want to limit it.
sorry but im not an advanced html/php coder, so what will the code be
?

We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
Within the script tag you would add:
var count = 0;
Then within the clicked event you would add:
if (count < 3)//if you only want 3 text inputs max.
{
count++;
//rest of the clicked event here
}
var count = 0;
Then within the clicked event you would add:
if (count < 3)//if you only want 3 text inputs max.
{
count++;
//rest of the clicked event here
}
Thank You mandai
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
7 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023