I have a website app http://firstusadata.com/cash_flow_test/ that I would like to add some functionality to, yet have been unsuccessful.
The idea is to be able to add a vendor information form with one button click, and then be able to add products to that specific vendor information form with a different button click. The image below shows the Vendor Information Button as well as the add product button.
Vendor and Product Button areas
Currently if I remove the dynamic html function for the vendor information form (div id="dynamic_content_1"), as seen below, the add product button works and it will append the new product line underneath the previous. I believe my error is located somewhere in this area, but I am unsure.
function dynamic_html(){
var content = '<div id="dynamic_content_1">'
+'<div class="row">'
+'<div class="col-sm-8 col-sm-offset-2 SecPageMain">'
+'<h3>Vendor Information</h3>'
+'<form method="post" action="http://firstusadata.com/cash_flow/companies/insert_company_information">'
+'<div class="row margin_top_25">'
+'<div class="col-md-4 col-md-offset-1 col-sm-12">'
+'<p>Name of Company:</p>'
+'</div>'
+'<div class="col-md-6 col-sm-12">'
+'<input type="text" class="form-control pull-left w100" name="company_name" required='' >'
+'</div>'
+'</div>'
+'<div class="row margin_top_25">'
+'<div class="col-md-4 col-md-offset-1 col-sm-12">'
+'<p>Company Phone Number:</p>'
+'</div>'
+'<div class="col-md-6 col-sm-12">'
+'<input type="text" class="form-control pull-left w100" id="" name="company_phone" required='' >'
+'</div>'
+'</div>'
+'<div class="row margin_top_25">'
+'<div class="col-md-5 col-md-offset-1 col-sm-12">'
+'<p>Did this company build your website?</p>'
+'</div>'
+'<div class="col-md-5 col-sm-12">'
+'<div class="radio radio-info radio-inline" >'
+'<input type="radio" value="1" name="built_website">'
+'<label for="inlineRadio1"> Yes </label>'
+'</div>'
+'<div class="radio radio-inline">'
+'<input type="radio" value="0" name="built_website" checked>'
+'<label for="inlineRadio2"> No </label>'
+'</div>'
+'</div>'
+'</div>'
+'<div class="hide" id="BuildWebsite" >'
+'<div class="row margin_top_10">'
+'<div class="col-md-4 col-md-offset-1 col-sm-12">'
+'<p>Website URL:</p>'
+'</div>'
+'<div class="col-md-6 col-sm-12">'
+'<input type="text" class="form-control pull-left w100" id="website_url" name="website_url">'
+'</div>'
+'</div>'
+'<div class="row margin_top_10">'
+'<div class="col-md-4 col-md-offset-1 col-sm-12">'
+'<p>Type of Website:</p>'
+'</div>'
+'<div class="col-md-6 col-sm-12">'
+'<select class="form-control w100" id="type_of_website" name="type_of_website">'
+'<option value="Amazon Store">Amazon Store</option>'
+'<option value="Affiliate">Affiliate</option>'
+'<option value="Drop Ship">Drop Ship</option>'
+'<option value="Lead Generation">Lead Generation</option>'
+'<option value="Small Business">Small Business</option>'
+'<option value="Landing Page">Landing Page</option>'
+'</select>'
+'</div>'
+'</div>'
+'<div class="row margin_top_10 category_area" style="display:none">'
+'<div class="col-md-4 col-md-offset-1 col-sm-12">'
+'<p>Category:</p>'
+'</div>'
+'<div class="col-md-6 col-sm-12">'
+'<select class="form-control w100" id="website_category" name="website_category">'
+'<option value="">Select category</option>'
+'</select>'
+'</div>'
+'</div>'
+'<div class="row margin_top_10">'
+'<div class="col-md-4 col-md-offset-1 col-sm-12">'
+'<p>Average Profit Margin Per 100 Users:</p>'
+'</div>'
+'<div class="col-md-6 col-sm-12">'
+' <input type="text" class="form-control pull-left w100 price" id="average_profit" name="average_profit">'
+'</div>'
+'</div>'
+'</div>'
+'<div id="dynamic_content_2">'
+'<div class="row margin_top_25 form-inline product_row">'
+'<div class="col-sm-3 col-sm-offset-1">'
+'<div class="form-group w100">'
+'<input type="" class="form-control w100" id="" name="product_name[]" placeholder="Product" required>'
+'</div>'
+'</div>'
+'<div class="col-sm-2">'
+'<div class="form-group w100">'
+'<input type="" class="form-control w100 price" id="" name="product_price[]" placeholder="Price" required>'
+'</div>'
+'</div>'
+'<div class="col-sm-3">'
+'<select class="form-control w100" name="product_type[]" required>'
+'<option value="">Select</option>'
+'<option value="Web Development">Web Development</option>'
+'<option value="Business Development">Business Development</option>'
+'</select>'
+'</div>'
+'<div class="col-sm-3">'
+'<div class="btn-inline margin_left_25">'
+'<button type="button" class="btn plusbtn btn-default pull-left">'
+'<i class="fa fa-plus"></i>'
+'</button>'
+'<button type="button" class="btn btn-default minusbtn pull-left">'
+'<i class="fa fa-minus"></i>'
+'</button>'
+'</div>'
+'</div>'
+'</div>'
+'</div>'
+'<h4>Add Vendor</h4>'
+'<div class="col-sm-3">'
+'<div class="btn-inline margin_left_25">'
+'<button type="button" class="btn testbutton1 btn-default pull-left">'
+'<i class="fa fa-plus"></i>'
+'</button>'
+'<button type="button" class="btn btn-default testbutton2 pull-left">'
+'<i class="fa fa-minus"></i>'
+'</button>'
+'</div>'
+'</div>'
+'</form>'
+'</div>'
+'</div>'
+' </div>';
return content;
}
I am fairly knew to jquery, so I may be missing something very obvious to those more experienced, I greatly appreciate the help.
At least in your fiddle, you have dynamic_html() defined twice. Your page should raise an error (f12 to open the console if you want to see this yourself).
Also this line
+'<input type="text" class="form-control pull-left w100" name="company_name" required='' >'
needs to have double quotes for the required field.