UnknownPlayer Posted October 31, 2010 Share Posted October 31, 2010 I have this javascript function: <script> fields = 5; function addInput() { if (fields <= 15) { document.getElementById('inputs').innerHTML += "<input type='text' value='' name='igraci[]' /><br />"; fields += 1; } else { document.getElementById('inputs').innerHTML += "<br />15 je dozvoljeno."; } } </script> And this PHP Code: <form action="klan.php?id='.$kid.'" method="post"> <p> <div id="inputs"> </div> <input class="button" type="button" onclick="addInput()" name="add" value="Dodaj jos igraca" /> <br /><br /> <input class="button" type="submit" name="sacuvaj" value="Posalji pozivnicu igracima" /> </p> </form>'; Now i have problem, when i click on button to add inputs, it add inputs, then i write in inputs some value, and when i wonna add more inputs, when click to add it remove all values on all inputs that was there :S How can i just add input, not to remove value on previous inputs ? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 31, 2010 Share Posted October 31, 2010 You need to create an element and append it to document. You are currently rewiring the innerHTML. Since your question is actually a javascript question and not a php question, moving this to the correct forum section... Quote Link to comment Share on other sites More sharing options...
UnknownPlayer Posted October 31, 2010 Author Share Posted October 31, 2010 Then, can you or someone else give me an example, how to do that? Quote Link to comment Share on other sites More sharing options...
UnknownPlayer Posted November 2, 2010 Author Share Posted November 2, 2010 Anyone ? :S Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 2, 2010 Share Posted November 2, 2010 There are working add an input field scripts posted all over the Internet. Have you even tried to search for one that appends a field? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.