I am working on a website and I am trying to figure out how to add a wildcard to the following code for author1_name
:
$(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').last().after('<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 author-remove-group author-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++;
});
$("#article_name").autocomplete({
source: 'articlesearch.php'
});
$("#author1_name").autocomplete({
source: 'authorsearch.php'
});
$("#author2_name").autocomplete({
source: 'authorsearch.php'
});
$("#author3_name").autocomplete({
source: 'authorsearch.php'
});
$("#author4_name").autocomplete({
source: 'authorsearch.php'
});
$("#author5_name").autocomplete({
source: 'authorsearch.php'
});
$("#author6_name").autocomplete({
source: 'authorsearch.php'
});
$("#author1_university").autocomplete({
source: 'universitysearch.php'
});
$("#author2_university").autocomplete({
source: 'universitysearch.php'
});
$("#author3_university").autocomplete({
source: 'universitysearch.php'
});
$("#author4_university").autocomplete({
source: 'universitysearch.php'
});
$("#author5_university").autocomplete({
source: 'universitysearch.php'
});
$("#author6_university").autocomplete({
source: 'universitysearch.php'
});
});
I'd like it to place a wildcard to the number in the author1_name
and author1_university
so that I don't have to repeat the selector multiple times in my code. Your help is greatly appreciated.