i new javascript. , trying create page used writing reviews. stuck @ point.
there should button add section copies whole sections div allow user write section.
attached below code. using ckeditor plugin allow end user format text wish.
the current code , while creating new section, doesn't allow user write text area created. please guide me mistaken.
<?php include 'settings.php'; if (!isset($dbc)){ $dbc = new mysqli(db_host , db_user , db_password , db_name); } if ($dbc -> connect_error){ die ("cannot connect database"); } ?> <html> <head> <title>write new review.</title> <script type="text/javascript" src="ckeditor/ckeditor.js"></script> </head> <body> <form id = "new_review" action = "form.php" method = "post"> <div id = "header"> <h2> header section. </h2> author : <input type = "text" id = "author"> <br> title: <input type = "text" id = "title"> <br> tagline: <input type = "text" id = "tagline" > <br> score: <input type = "text" id = "score" > <br> pros: <textarea class = "ckeditor" id = "pros"> please enter pro's of product here. </textarea> cons: <textarea class = "ckeditor" id = "cons"> please enter cons of product here. </textarea> verdict:<textarea class = "ckeditor" id = "verdict"> enter vedict here. </textarea> </div> <div id = "sections"> <h2> sections. </h2> <input type = "button" id="button" onclick="duplicate()">add section</button> <div class = "section_base" id = "section"> section icon: <input type="file" id="icon" accept="image/*"> <br> section title: <input type = "text" id = "section_title" > <br> section text: <textarea class = "ckeditor" id = "section_text"> enter text here. </textarea> section score: <input type = "text" id = "section_score"> </div> </div> <div id = "conclusion"> <h2> conclusion: </h2> <textarea class = "ckeditor" id = "conclusions"> enter conclusion here. </textarea> </div> <input type = "submit" value="submit"> </form> <script type="text/javascript"> var = 0; var original = document.getelementbyid('section'); function duplicate() { var clone = original.clonenode(true); // "deep" clone clone.id = "section" + ++i; // or clone.id = ""; if divs don't need id original.parentnode.appendchild(clone); } </script> </body> </html> below links had information did.
http://ckeditor.com/ckeditor_4.3_beta/samples/replacebyclass.html
try javascript
<script type="text/javascript"> var = 1; function duplicate() { var clone = '<div class = "section_base" id = "section">section icon: <input type="file" id="icon" accept="image/*"> <br> section title: <input type = "text" id = "section_title" > <br> section text: <textarea id = "section_text'+i+'"> enter text here. </textarea>section score: <input type = "text" id = "section_score"> </div>'; var div = document.getelementbyid('sections'); var newdiv = document.createelement('div'); newdiv.innerhtml = clone; div.appendchild(newdiv); ckeditor.replace('section_text'+i); i++; } </script>
Comments
Post a Comment