JavaScript Adding Dynamic Input - Not Appending Correctly - Picture included dynamic adding new input field,dynamic adding new input field

I have included javascript for dynamically adding input fields but the first time its clicked it doesn't style correctly. Here is how it looks before utilizing add button (ignore the Author 1/University 1 showing up 2x, its in my code for reference):Here is how it looks in beginning

and here is how it looks after clicking it a few times:

enter image description here As you can see the first addition doesn't style correctly.

I was also wondering if anyone knows how I can create a delete author field button, in order to subtract an input field if you do not need it.

Here is my code:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Input Form - Research Ranker</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" target='_blank' href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <link rel="shortcut icon" target='_blank' href="/../img/favicon.ico">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <link rel="stylesheet" target='_blank' href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
   <script>
  $(function() {
	var num = 2;
	var id = 'author' +num;
	var uni_id = 'university' +num;
	$( "#AuthorFieldButton" ).click(function() {
    var name = 'Author '+ num;
	var uni_name = 'University ' + num;
	id = 'author' + num;
    $('.author-group').append('<div class="form-group"> <label class="col-md-4 control-label" for="'+id+'">'+name+':</label><div class="col-md-4"><input type="text" id="'+id+'" name="'+id+'" class="form-control input-md" maxlength="40" ></div></div><div class="form-group"><label class="col-md-4 control-label" for="'+uni_id+'">'+uni_name+':</label><div class="col-md-4"><input type="text" id="'+uni_id+'" name="'+uni_id+'" class="form-control input-md maxlength="55" ></div></div>')
	num++;
	// <div class="form-group">
	//  <label class="col-md-4 control-label" for="author1_name">Author 1:</label>  
	//  <div class="col-md-4">
	//  <input id="author1_name" name="author1_name" type="text" placeholder="Author Name" class="form-control input-md" required="" maxlength="40">
		
	//  </div>
	// </div>

  });
  });
	</script>
</head>

<body>
<?PHP
 
if(!isset($_POST['submit'])){
    print '
	<div class="container-fluid ui-widget">


	<form class="form-horizontal" method="post" action="articleinput2.php" onsubmit="return confirm("Is all of your data correct?");">
	<fieldset>

	<!-- Article Input -->
	<legend>Article Input</legend>

	<!-- Journal Radio Buttons (value is journal ISSN)-->
	<div class="form-group">
	  <label class="col-md-4 control-label" for="journal_radio">Journal</label>
	  <div class="col-md-4">
	  <div class="radio">
		<label for="journal_radio-0">
		  <input type="radio" name="journal_radio" id="journal_radio-0" value="2162-9730" checked="checked">
		  MIS Quarterly
		</label>
	  </div>
	  <div class="radio">
		<label for="journal_radio-1">
		  <input type="radio" name="journal_radio" id="journal_radio-1" value="1047-7047">
		  Information Systems Research
		</label>
	  </div>
	  <div class="radio">
		<label for="journal_radio-2">
		  <input type="radio" name="journal_radio" id="journal_radio-2" value="0742-1222">
		  Journal of Management Information Systems
		</label>
	  </div>
	  <div class="radio">
		<label for="journal_radio-3">
		  <input type="radio" name="journal_radio" id="journal_radio-3" value="1536-9323">
		  Journal of the Association for Information Systems
		</label>
	  </div>
	  <div class="radio">
		<label for="journal_radio-4">
		  <input type="radio" name="journal_radio" id="journal_radio-4" value="1476-9344">
		  European Journal of Information Systems
		</label>
	  </div>
	  <div class="radio">
		<label for="journal_radio-5">
		  <input type="radio" name="journal_radio" id="journal_radio-5" value="1365-2575">
		  Information Systems Journal
		</label>
	  </div>
	  <div class="radio">
		<label for="journal_radio-6">
		  <input type="radio" name="journal_radio" id="journal_radio-6" value="0963-8687">
		  Journal of Strategic Information Systems
		</label>
	  </div>
	  <div class="radio">
		<label for="journal_radio-7">
		  <input type="radio" name="journal_radio" id="journal_radio-7" value="0268-3962">
		  Journal of Information Technology
		</label>
	  </div>
	  <div class="radio">
		<label for="journal_radio-8">
		  <input type="radio" name="journal_radio" id="journal_radio-8" value="0167-9236">
		  Decision Support Systems
		</label>
	  </div>
	  <div class="radio">
		<label for="journal_radio-9">
		  <input type="radio" name="journal_radio" id="journal_radio-9" value="0378-7206">
		  Information and Management
		</label>
	  </div>
	  </div>
	</div>

	<!-- Article Name Input-->
	<div class="form-group">
	  <label class="col-md-4 control-label" for="article_name">Article Name:</label>  
	  <div class="col-md-5">
	  <input id="article_name" name="article_name" type="text" placeholder="Article Name" class="form-control input-md" required="" maxlength = "60">
		
	  </div>
	</div>

	<!-- Author 1-->
	<div class="form-group">
	  <label class="col-md-4 control-label" for="author1_name">Author 1:</label>  
	  <div class="col-md-4">
	  <input id="author1_name" name="author1_name" type="text" placeholder="Author Name" class="form-control input-md" required="" maxlength="40">
		
	  </div>
	</div>

	<!-- Author 1 University -->
	<div class="form-group">
	  <label class="col-md-4 control-label" for="author1_university">University:</label>  
	  <div class="col-md-4">
	  <input id="author1_university" name="author1_university" type="text" placeholder="Author University" class="form-control input-md" required="" maxlength="55">
		
	  </div>
	</div>
	<!-- Author 1 New Input Field-->
	 <div class="form-group ">
      <label class="col-md-4 control-label" for="author1">Author 1:</label>
	  <div class="col-md-4">
      <inputid="author1_name" name="author1_name" type="text" placeholder="Author Name" class="form-control input-md" required="" maxlength="40"">
    </div>
	</div>
	 
	<!-- University 1 New Input Field-->
	 <div class="author-group form-group">
      <label class="col-md-4 control-label" for="university1">University 1:</label>
	  <div class="col-md-4">
      <input id="author1_university" name="author1_university" type="text" placeholder="Author University" class="form-control input-md" required="" maxlength="55">
    </div>
	</div>
	<div class="form-group">
	<div class="col-md-4 control-label">
	<button class="btn-small btn-primary" id="AuthorFieldButton" type="button">+ Author</button> 
	</div>
	</div>
	
	<!-- Select Year Published -->
	<div class="form-group">
	  <label class="col-md-4 control-label" for="year">Year Published</label>
	  <div class="col-md-4">
		<select id="year" name="year" class="form-control">
		  <option value="2010">2010</option>
		  <option value="2011">2011</option>
		  <option value="2012">2012</option>
		  <option value="2013">2013</option>
		  <option value="2014">2014</option>
		  <option value="2015">2015</option>
		</select>
	  </div>
	</div>

	<!-- Is Security Checkbox -->
	<div class="form-group">
	  <label class="col-md-4 control-label" for="is_security"></label>
	  <div class="col-md-4">
		<label class="checkbox-inline" for="is_security">
		  <input type="checkbox" name="is_security" id="is_security" value="1">
		  Security Related
		</label>
	  </div>
	</div>

	<!-- Submit Form Button -->
	<div class="form-group">
	  <div class="col-md-4 control-label">
		<button id="submit" name="submit" class="btn btn-primary">Submit</button>
	  </div>
	</div>

	</fieldset>
	</form>


	</div>';
	
	}
Answer:1

I have been struggling to include a profile picture upload along with regular text data and send that all to the back end to create a new user through mongoose. I have tried everything from ng-file-...

I have been struggling to include a profile picture upload along with regular text data and send that all to the back end to create a new user through mongoose. I have tried everything from ng-file-...

  1. angular image upload with preview
  2. angular image upload component
  3. angular image upload npm
  4. angular image upload example
  5. angular image upload stackblitz
  6. angular image upload with crop
  7. angular image upload base64
  8. angular image upload library
  9. angular image upload validation
  10. angular image upload plugin
  11. angular image upload made easy
  12. angular image upload with spring boot
  13. angular image upload with preview example
  14. angular image upload firebase
  15. angular image upload .net core
  16. angular image upload and display
  17. angular image upload and retrieve with firebase storage
  18. angular image upload formdata
  19. angular image upload drag and drop
  20. angular image upload with form data

In my code, the x value is undefined. If I remove if block, the x value is displayed as 77. I don't understand why if block is modifying the x value. var x = 77; function fn() { if (false) {...

In my code, the x value is undefined. If I remove if block, the x value is displayed as 77. I don't understand why if block is modifying the x value. var x = 77; function fn() { if (false) {...

  1. javascript hoisting functions
  2. javascript hoisting why
  3. javascript hoisting let
  4. javascript hoisting quiz
  5. javascript hoisting const
  6. javascript hoisting es6
  7. javascript hoisting stack overflow
  8. javascript hoisting questions
  9. javascript hoisting interview questions
  10. javascript hoisting medium
  11. javascript hoisting mdn
  12. javascript hoisting tutorial
  13. javascript hoisting variables
  14. javascript hoisting definition
  15. javascript hoisting meaning
  16. javascript hoisting not working
  17. javascript hoisting advantages
  18. javascript hoisting order
  19. javascript hoisting problem
  20. javascript hoisting inside function

I have a JavaScript validation on form, every time the form is submitted it will empty the boxes. I need to change it, when the form is filled up incomplete with empty boxes. it will not clear all the ...

I have a JavaScript validation on form, every time the form is submitted it will empty the boxes. I need to change it, when the form is filled up incomplete with empty boxes. it will not clear all the ...

  1. styling input validation
  2. custom field validation message

I got myself stuck in a pyramid of doom using Promises. I have the following: getA getB getC getC depends on getB (and getA) that depends on getA. So I must call them like this getA(param) ....

I got myself stuck in a pyramid of doom using Promises. I have the following: getA getB getC getC depends on getB (and getA) that depends on getA. So I must call them like this getA(param) ....

  1. callback hell with promises
  2. callback hell in javascript
  3. callback hell in node js
  4. callback hell in js
  5. callback hell in node js example
  6. node js callback hell
  7. callback hell in node
  8. callback hell in java
  9. callback hell in angular 2
  10. callback hell in angular
  11. callback hell in swift
  12. callback hell in angularjs
  13. callback hell in react
  14. callback hell in javascript stackoverflow
  15. callback hell in angular 6
  16. callback hell in es6
  17. callback hell to rxjs
  18. callback hell in
  19. callback hell in typescript
  20. callback hell in ios