From: jr on
This one seems like it should work, I don't get syntax errors but the
problem is it doesn't work.
The script doesn't validate anything. If it is correct then something
else is wrong otherwise it is not validating
any of the values, thanks,

function checkscript() {
if ( search_bu.value && search_error_flag) {
if ( zoneid.value && !zonenum.value ) {return 1 }

}

return 0;
From: Denis McMahon on
On 03/08/10 07:13, jr wrote:

> function checkscript() {
> if ( search_bu.value && search_error_flag) {
> if ( zoneid.value && !zonenum.value ) {return 1 }
> }
>
> return 0;

I hope you had a "}" after the return 0?

I'm sure you're fully aware, having been told many times, that you can't
just use the field name or id to identify a field in javascript. You
have to translate that information somewhere into something the code
understands.

In fact, this is a fundamental concept that you should understand by now.

Irrespective of whether the logical flow of your code works (and as I
don't fully understand what you're trying to check, I can't verify
whether it will or not) I have no idea what the one variable and three
objects you're testing here are.

There are two ways to address objects relating to input elements in a
form from within javascript. One, which some people now consider
outdated, is as a named property of the parent form object, and the
other is using the element id. If using the named property of form
method, then you also need to identify the form, either as a member of
the document's forms collection, or as a named property of the document.

I have seen code that combines using the id of the form and then
referring to an input as a named property of that form, which is to me
illogical, as in my opinion if you're going to use element id attributes
you might as well use id at the input element level.

Once you have identified the object that relates to an input element on
a form, there is as one and only one common way to get the content of
that element.

Rgds

Denis McMahon
From: jr on
On Aug 3, 6:44 am, Denis McMahon <denis.m.f.mcma...(a)googlemail.com>
wrote:
> On 03/08/10 07:13, jr wrote:
>
> > function checkscript() {
> >    if ( search_bu.value  && search_error_flag) {
> >      if ( zoneid.value && !zonenum.value ) {return 1 }
> >    }
>
> >  return 0;
>
> I hope you had a "}" after the return 0?
>
> I'm sure you're fully aware, having been told many times, that you can't
> just use the field name or id to identify a field in javascript. You
> have to translate that information somewhere into something the code
> understands.
>
> In fact, this is a fundamental concept that you should understand by now.
>
> Irrespective of whether the logical flow of your code works (and as I
> don't fully understand what you're trying to check, I can't verify
> whether it will or not) I have no idea what the one variable and three
> objects you're testing here are.
>
> There are two ways to address objects relating to input elements in a
> form from within javascript. One, which some people now consider
> outdated, is as a named property of the parent form object, and the
> other is using the element id. If using the named property of form
> method, then you also need to identify the form, either as a member of
> the document's forms collection, or as a named property of the document.
>
> I have seen code that combines using the id of the form and then
> referring to an input as a named property of that form, which is to me
> illogical, as in my opinion if you're going to use element id attributes
> you might as well use id at the input element level.
>
> Once you have identified the object that relates to an input element on
> a form, there is as one and only one common way to get the content of
> that element.
>
> Rgds
>
> Denis McMahon

okay, that makes sense so if I do this ele.search_bu.value, I should
do ele= document.form[0], I think that was what was missing,
thanks, you are right I should have seen it.
From: jr on
On Aug 3, 6:44 am, Denis McMahon <denis.m.f.mcma...(a)googlemail.com>
wrote:
> On 03/08/10 07:13, jr wrote:
>
> > function checkscript() {
> >    if ( search_bu.value  && search_error_flag) {
> >      if ( zoneid.value && !zonenum.value ) {return 1 }
> >    }
>
> >  return 0;
>
> I hope you had a "}" after the return 0?
>
> I'm sure you're fully aware, having been told many times, that you can't
> just use the field name or id to identify a field in javascript. You
> have to translate that information somewhere into something the code
> understands.
>
> In fact, this is a fundamental concept that you should understand by now.
>
> Irrespective of whether the logical flow of your code works (and as I
> don't fully understand what you're trying to check, I can't verify
> whether it will or not) I have no idea what the one variable and three
> objects you're testing here are.
>
> There are two ways to address objects relating to input elements in a
> form from within javascript. One, which some people now consider
> outdated, is as a named property of the parent form object, and the
> other is using the element id. If using the named property of form
> method, then you also need to identify the form, either as a member of
> the document's forms collection, or as a named property of the document.
>
> I have seen code that combines using the id of the form and then
> referring to an input as a named property of that form, which is to me
> illogical, as in my opinion if you're going to use element id attributes
> you might as well use id at the input element level.
>
> Once you have identified the object that relates to an input element on
> a form, there is as one and only one common way to get the content of
> that element.
>
> Rgds
>
> Denis McMahon

I tried it like this and it still doesn't fire. there are 4 fields in
a search form. The first 2 required. The zonenm is only required if
there is no zoneid. IT seems like it should work. Rgds, Janis
function checkscript() {
// If bu and error_flag have a value return 0, if zoneid has a value
without zonenm proceed to next check
var ele=document.forms[0];
if (ele.search_bu.value && ele.search_error_flag.value ) {
// If zoneid has a value and zonenm does not have a value
return false
if (ele.search_zoneid.value && !ele.search_zonenm.value) {
return 1;
} else {
// if zoneid doesn't have a value, or
// if both zoneid and zonenm have values
return 0;
}
// If either bu or error_flag (or both) don't have a value
} else {
return 1;
}
}

</script>
Regards,
Janis
From: Gregor Kofler on
Am 2010-08-03 17:34, schrieb jr:

> okay, that makes sense so if I do this ele.search_bu.value, I should
> do ele= document.form[0], I think that was what was missing,

document.form*s*[0].elements["search_blu"];

> thanks, you are right I should have seen it.

Erm...

Gregor