louisstephens Posted March 18, 2009 Share Posted March 18, 2009 Alrighty, I come to you all with another question. So far I have a form with a file upload, and a button under it that says "add" (to add another picture). I simply would like once the "add" button is clicked, for another upload field to "appear" under the previous one using php. It seemed pretty straight forward to me, but I can not figure it out Link to comment https://forums.phpfreaks.com/topic/149918-if-isset-display-another-upload-field/ Share on other sites More sharing options...
9three Posted March 18, 2009 Share Posted March 18, 2009 Show your code so we can assist further. Link to comment https://forums.phpfreaks.com/topic/149918-if-isset-display-another-upload-field/#findComment-787400 Share on other sites More sharing options...
louisstephens Posted March 18, 2009 Author Share Posted March 18, 2009 <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> <label> <input type="file" name="u1" id="u1" /> </label> <label> <input type="submit" name="add" id="add" value="add" /> </label> </form> <?php if (isset($_POST['add'])) { echo <label> <input type="file" name="u2" id="u2" /> </label> ?> Link to comment https://forums.phpfreaks.com/topic/149918-if-isset-display-another-upload-field/#findComment-787421 Share on other sites More sharing options...
tracivia Posted March 18, 2009 Share Posted March 18, 2009 if you do that with PHP, the window will be refreshed. So the upload fields will be reset too. The proper way of doing this is, using javascript. Put all your content in a certain div <div id="certain_div"><input uploadfield blabla><button onclick="addfield();"></div> function addfield(){ var holder = document.getElementById('certain_div'); holder.innerHTML += '<another uploadfield>'; } Link to comment https://forums.phpfreaks.com/topic/149918-if-isset-display-another-upload-field/#findComment-787437 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.