Can someone help me figure out how to clone a specic section of html when a link is clicked?
When the user clicks
I want to duplicate this entire fieldsetHTML Code:<a href="" onClick="cloneDiv();" >Add Additional Positions:</a>
HTML Code:<fieldset id='addPosition'> <legend>Add Project Position:</legend> <li> <label for="positions">Position:</label> <select name='genre' > <option value="1">Actor</option> <option value="2">Actress</option> <option value="3">Director</option> <option value="4">Cinematographer</option> <option value="5">Producer</option> <option value="6">Writer</option> <option value="7">Miscellaneous Crew</option> <option value="8">Animator</option> <option value="9">Sound Mixer</option> </select> <span class="form_hint">Select Position. </span> </li> <li> <label for="job_title">Position Title:</label> <input type="text" name="project_title" placeholder="Project Title" /> <span class="form_hint">Enter a title/name for position</span> </li> <li> <label for="job_detail">Position Detail:</label> <textarea name="job_detail" cols="40" rows="4"></textarea> </li> </fieldset>
here is the start of my function. I'm not sure how to use the clone method or how to display what it clones. I want the new fieldset to appear below the fieldset it cloned and above the link. I included the entire file with a comment indicating where I need it to go.
HTML Code:<script language="JavaScript"> function cloneDiv(){ var clonenode = document.getElementById("addPosition"); //alert(); } </script>HTML Code:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Upload Project</title> <link rel="stylesheet" media="screen" href="css/form.css" > <script language="JavaScript"> function cloneDiv(){ //var clonenode = document.getElementById("addPosition"); alert(); } </script> </head> <body> <form class="contact_form" action="scripts/procProjectForm.php" method="post" name="contact_form" enctype="multipart/form-data"> <ul> <li> <h2>Start A Project</h2> <span class="required_notification">* Denotes Required Field</span> </li> <li> <label for="project_title">Project Title:</label> <input type="text" name="project_title" placeholder="Project Title" required /> <span class="form_hint">Enter a title for new project</span> </li> <fieldset id='addPosition'> <legend>Add Project Position:</legend> <li> <label for="positions">Position:</label> <select name='genre' > <option value="1">Actor</option> <option value="2">Actress</option> <option value="3">Director</option> <option value="4">Cinematographer</option> <option value="5">Producer</option> <option value="6">Writer</option> <option value="7">Miscellaneous Crew</option> <option value="8">Animator</option> <option value="9">Sound Mixer</option> </select> <span class="form_hint">Select Position. </span> </li> <li> <label for="job_title">Position Title:</label> <input type="text" name="project_title" placeholder="Project Title" /> <span class="form_hint">Enter a title/name for position</span> </li> <li> <label for="job_detail">Position Detail:</label> <textarea name="job_detail" cols="40" rows="4"></textarea> </li> </fieldset> <!-- cloned fieldset goes here--> <fieldset> <legend><a href="" onClick="cloneDiv();" >Add Additional Positions:</a></legend> </fieldset> <li> <button class="submit" type="submit" value="Upload">Submit Form</button> </li> </ul> </form> </body> </html>



Reply With Quote





Bookmarks