[ create a new paste ] login | about

Link: http://codepad.org/DtbOsXga    [ raw code | fork | 1 comment ]

C, pasted on Nov 18:
Dynamic Input
var counter = 1;
var limit = 20;
var imageText = `<input id="productImage" name="productImage[]" type="file" class="file" data-preview-file-type="text" required>`;
function addInput(divName){
     if (counter == limit)  {
          alert("You have reached the limit of adding " + counter + " inputs");
     else {
          var newdiv = document.createElement('div');
          newdiv.innerHTML = "<br><h5>Product " + (counter + 1) + "</h5> <div class='row'><section class='unit span6'>Name<br><input placeholder='Name of product' type='text' name='productName[]' required></section><section class='unit span6'>Price<br><input placeholder='Price of product' type='text' name='productPrice[]' required></section></div><br />Description<br><div class='textarea relative'><label class='icon-append' for='message'><i class='fa fa-align-left'></i></label><textarea placeholder='Describe the product' name='productDescription[]' title='Type the product description here!' required></textarea></div><br />Product Image<br>" + imageText;


<div id="dynamicInput">
				<center>Please note that you will be able to add products to your site in the future.  You do not have to add all your products right now, however we need some products to get your site built.</center>
					<h5>Product 1</h5>
					<div class="row">
					<section class="unit span6">Name<br><input placeholder="Name of product" type="text" name="productName[]" required></section>
					<section class="unit span6">Price<br><input placeholder="Price of product" type="text" name="productPrice[]" required></section>
					<br />
					Description<br><div class="textarea relative">
										<label class="icon-append" for="message">
											<i class="fa fa-align-left"></i>
										<textarea placeholder="Describe the product" name="productDescription[]" title="Type the product description here!" required></textarea>
					<br />
					Product Image<br>
					<input id="productImage" name="productImage[]" type="file" class="file" data-preview-file-type="text" required>

Create a new paste based on this one

posted by zafar on Mar 6