If I pass a form to a Javascript validation function, what is the syntax to access the values in the fields if I don't know the form's name?
I pass it in the HTML like so:
<form method=... action=...>
<input type="text" name="qty-box" value="100" onkeydown="if (event.keyCode == 13) addBoxSubmit(this);" />
</form>
Now in my javascript function like so:
function addBoxSubmit (myForm) {
//how to access the form values none of these methods worked,
//I need to know the correct syntax
//I tried myform.['qty-box'].value;
//I tried myForm['qty-box'].value;
//I tried document.myForm.['qty-box'].value;
//I tried document.myForm['qty-box'].value;
}
For this application I will have many forms on the page that I want to use with my validation function, essentially each row on a data table is its own form. I can't just access the forms by name because they are dynamically generated serialized names.
qty-boxand thendocument.getElementById('qty-box'). Or simplydocument.qty-box, but one problem may be that Javascript does not like the object name to have a - in it, as that is the minus sign in Javascript.