I want to be able to test if theForm is defined, meaning it found a form with the name ‘data’
How do we do that?
Then if it is not found I can test for the other form name and set the action on that named form.
function edit_OnClick() {
var theForm = window.document.forms['data'];
theForm.action = "checkout.asp";
theForm.submit();
return false;
}
Is it ok to post follow ups at stackoverflow?
This is what I came up with using your advice, but it is not switching like I planned.
function edit_OnClick() {
var theForm = window.document.forms['data'];
if ( typeof ( theForm !== "undefined" )) {
theForm.action = "checkout.asp";
theForm.submit();
return false;
}else {
var theForm = window.document.forms['form_bml'];
theForm.action = "checkout.asp";
theForm.submit();
return false;
}
}
You could use:
If the actions for both are the same, then: