Use .val()
, because you're using a jQuery selector in which .value
is not defined.
Your new JavaScript/JQuery:
function dosubmit() {
$('#addItemForm').submit();
}
$(document).ready(function () {
//this is intended to prevent enter key from submitting the form
$('#addItemForm').bind('keydown', function (e) {
if (e.keyCode == 13 || e.which == 13) {
e.preventDefault();
e.stopPropagation();
var addbtn = $('#additembutton');
$(addbtn).click();
return false;
}
});
$('#addItemForm').submit(function (ev) {
ev.preventDefault(); // to stop the form from submitting
log("made it to the form submit function");
var varz = [];
var i = 0;
$('#form_list_parent').find('input').each(function () {
log("INPUT: " + i);
//log(dump($(this)));
var txt = $(this).val();
log(txt); // always comes back 'undefined' ??
varz.push(txt);
i += 1;
});
/* Validations go here */
//this.submit(); // only submit If all the validations succeeded
});
});
function addAnotherItem() {
var input = document.createElement("input");
input.type = "text";
input.id = "dyntext";
input.name = input.id;
input.value = "";
var br = document.createElement("br");
$('#form_list_parent').append(input);
$('#form_list_parent').append(br);
$(input).focus();
}