Trying to validate to 1.0 strict doc type
html for a form looks like this:
%26lt;form id=%26quot;form1%26quot; name=%26quot;form1%26quot; action=%26quot;receipt.php%26quot; method=%26quot;get%26quot; onsubmit=%26quot;return checkForm1()%26quot;%26gt;
will not validate due to %26quot;name %26quot;tag
how do I change script to get by ID
sample of script:
function calcPrice() {
product = document.form1.prod;
pindex = product.selectedIndex;
product_price = product.options[pindex].value;
quantity = document.form1.qty;
Please be specific.
Thanx
Javascript changing %26quot;name%26quot; to %26quot;ID%26quot;?
%26lt;form id=%26quot;form1%26quot; action=%26quot;receipt.php%26quot; method=%26quot;get%26quot; onsubmit=%26quot;return checkForm1()%26quot;%26gt;
function calcPrice() {
product = document.form1.prod;
pindex = product.selectedIndex;
product_price = product.options[pindex].value;
quantity = document.form1.qty;
}
... will work.
but:
function calcPrice() {
product = document.forms['form1'].prod;
pindex = product.selectedIndex;
product_price = product.options[pindex].value;
quantity = document.forms.['form1'].qty;
... is better and ...
%26lt;form action=%26quot;receipt.php%26quot; method=%26quot;get%26quot; onsubmit=%26quot;return checkForm1(this)%26quot;%26gt;
function checkForm1(frm) {
product = frm.prod;
pindex = product.selectedIndex;
product_price = product.options[pindex].value;
quantity = frm.qty;
... is best.