I have a form that is accessible via the web which contains four fields. The first field is a search type field, where the user can perform a search by Date, Topic or Keyword. The other three fields are a dialog list for Date, a dialog lsit for Topic and a text box for Keyword - each of which are hidden fields, until a search type is selected.
Below I am including my code - sorry that it is a little long, but I want to make sure that all of the information is provided!
In the JSHeader, I have the following field validation code:
function validateAll(form)
{
if (form.SearchType.options[1].selected)
{
if (form.Date.options[0].selected)
{
alert ("Please select the semniar date.");
form.Date.focus();
return false;
}
}
if (form.SearchType.options[2].selected)
{
if (form.Topic.options[0].selected)
{
alert ("Please select a semniar topic.");
form.Topic.focus();
return false;
}
}
if (form.SearchType.options[3].selected)
{
if (form.Keyword.value=="")
{
alert ("Please enter keyword(s) in space provided.");
form.Topic.focus();
return false;
}
}
if (form.SearchType.options[0].selected)
{
alert (“Please select type of search.”);
form.SearchType.focus();
return false;
}
}
On the Display Results action button, I have the following code:
// if (validateAll(document.forms[0]) )
//{
//document.forms[0].submit()
//}
//else
//{
//document.forms[0].focus()
//return false
//}
alert(validateAll(document.forms[0]));
I commented out the code and placed an alert so that I could determine the problem.
Then on the WebQuerySave, I run my agent:
@Command([ToolsRunMacro]; “QueryData”)
If I do not select a search type, I get the following popup messages (alert messages):
Please select search type.
false
If I select a search type (i.e. Date) and do not select a Date from the list which appears I get a similar message:
Please select seminar date.
false
If I ensure that all of the criteria has been entered (i.e. select serach type Date and select a seminar date from the list) I get the following:
undefined
and my query does not run.
Does this ‘undefined’ result have something to do with the fact that some of my fields are hidden and do not contain values? If so, how can I overcome this problem?
Any ideas or suggestions would be greatly appreciated. Thanks in advance.