By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,685 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,685 IT Pros & Developers. It's quick & easy.

cloneNode just under cloned element

P: 25
hello, i need help with this javascript
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. function addfile()
  4. {
  5. var obj = document.getElementById("sprytextfield2").cloneNode(true);
  6. document.body.appendChild(obj);
  7. }
  8.  
  9. </script>
and i want to change it somehow to copy my form input just under it.
not to the body of document.

here is the rest of code
Expand|Select|Wrap|Line Numbers
  1. <fieldset class="border" id="upfiles">
  2.         <legend>Vymazať fotku v profile pod albumom:</legend>
  3.         <label for="pod_albumom_photo_id[]">ID fotky:</label><br />
  4.         <span id="sprytextfield2">
  5.         <input type="text" name="pod_albumom_photo_id[]" value="" onKeyPress="ipt_onkeypress()" />
  6. <span class="textfieldInvalidFormatMsg">Iba cifry prosím. </span></span>
  7. <input
  8. class="button"
  9. type="button"
  10. value="Pridať pole"
  11. onclick="return addfile()" />
  12.  
  13.  
  14.         </fieldset>
  15.  
Aug 6 '09 #1
Share this Question
Share on Google+
2 Replies


Canabeez
100+
P: 126
can't you just append it to the fieldset?
Expand|Select|Wrap|Line Numbers
  1. function addFile(){
  2. var obj = document.getElementById("sprytextfield2").cloneNode(true);
  3. document.getElementById('upfiles').appendChild(obj);
  4. }
  5.  
Aug 6 '09 #2

P: 25
omg, it works, i was so stupid, i already tried that but didn't use quotations on upfiles. Thanks :D
Aug 6 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.