From: Denis McMahon on
On 03/08/10 20:06, jr wrote:

> This is the submit button in the view source:
> <td colspan='13' align='center'><input type='submit' name='submit1'
> value = ' Search'>
>
> This is the form post in view source:
> <form action='/tools/cart_inventory/cart_order_review.php'
> onSubmit='return checkscript();' method='post'>

I believe that onsubmit expects a boolean value, but you are returning a
numeric value. Is it possible that your return values are not being
interpreted as you expect?

Perhaps it would be better to actually return true or false from your
validation function, instead of 1 or 0.

Rgds

Denis McMahon
From: jr on
On Aug 3, 2:31 pm, Denis McMahon <denis.m.f.mcma...(a)googlemail.com>
wrote:
> On 03/08/10 20:06, jr wrote:
>
> > This is the submit button in the view source:
> > <td colspan='13' align='center'><input type='submit' name='submit1'
> > value = ' Search'>
>
> > This is the form post in view source:
> > <form action='/tools/cart_inventory/cart_order_review.php'
> > onSubmit='return checkscript();'  method='post'>
>
> I believe that onsubmit expects a boolean value, but you are returning a
> numeric value. Is it possible that your return values are not being
> interpreted as you expect?
>
> Perhaps it would be better to actually return true or false from your
> validation function, instead of 1 or 0.
>
> Rgds
>
> Denis McMahon

I will try that thanks,
From: jr on
On Aug 3, 12:26 pm, Tim Streater <timstrea...(a)waitrose.com> wrote:
> In article
> <f6ec9359-25fc-473c-84f9-4bfb6f234...(a)a4g2000prm.googlegroups.com>,
>
>  jr <jlro...(a)yahoo.com> wrote:
> > there is only one submit button, a search form. There are two sql's in
> > an if/else but only one search form and one result set. I called it
> > submit1 but it doesn't work if I call it just submit.  rgds, Janis
>
> Can you explain what you mean by: "There are two sql's in an if/else but
> only one search form and one result set." Where are they?
>
> --
> Tim
>
> "That excessive bail ought not to be required, nor excessive fines imposed,
> nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

Sure it was a cross over from mysql/php I probably didn't need to
mention it here on this list but there is an if/then that pulls
different rows of records depending on the values selected to search
on in the search box. It so happens if there is an error then there
is no match key and the sql is only on the one table of records so it
displays different results if there is amatch key then all the columns
are returned.
From: Lasse Reichstein Nielsen on
jr <jlrough(a)yahoo.com> writes:

> This one seems like it should work, I don't get syntax errors but the
> problem is it doesn't work.

"Doesn't work" isn't a very good error description.
I'm going to harp on this again at the end, please stay tuned :)

> 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;

There is far too little context here to say what's not working.
We can't ses what the variables "search_bu", "search_error_flag" etc.
refer to (if anything).

I'm assuming this is a form validation. In that case, I recommend
passing the form as a parameter to the function and make explicit
lookups in its elements array. E.g.

<form action="..." onsubmit="return checkscript(this);">
<input type="text" name="search_bu" ...
</form>
<script>
function checkscript(form) {
var elems = form.elements;
return elems['search_bu'].value != ""
&& elems['search_error_flag'].checked
&& elems['zoneid'].value != ""
&& Number(elems['zonenum'].value) != 0;
// You must return *false* to cancel the submit,
// 0 isn't good enough.
}
</script>

Here I'm guessing that the input control with name 'search_error_flag'
is a checkbox, and the rest are text inputs of some sort, with the
content of 'zonenum' being interpreted as a number.



In general (and that's not just for you), to get good help with a
problem you need to provide enough information for the reader to
reproduce, recognize and repair the problem. That means:

Reproduce: What did you do - all the code necessary to try it, but
please cut it down to a small self-contained example that still
exhibits the problem. If it's more than a few lines, a link to a
page is also good.
Recognize: What happened - be specific. "Nothing happened" isn't
as good as "there was no visible change on the page".
Repair: What did you expect to happen - again, be specific.

Without either of these, you will have people either guessing (which
is likely to be a waste of both their time and your chance of getting
a good answer) or saying an ironic "You did something wrong, try
something else".

Best of luck
/L
--
Lasse Reichstein Holst Nielsen
'Javascript frameworks is a disruptive technology'

From: Dr J R Stockton on
In comp.lang.javascript message <3ade0983-7b2e-4351-87f9-4cb9b5f51831(a)f6
g2000pro.googlegroups.com>, Tue, 3 Aug 2010 08:44:02, jr
<jlrough(a)yahoo.com> posted:

>
>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>


If you want to make helping you easy, you MUST post easily-readable,
easily-testable code.

Leave a gap between code and non-code.

Don't post a mismatched </script> or similar.

Use true & false for Booleans, not 1 & 0.

DO NOT ALLOW your posting agent to line-wrap code; preferably write code
with lines of 72 characters or fewer. Posted code must be RECEIVED as
executable code.

And "else" is rarely needed after "return", and IMHO should not be used
where not needed.

Read the FAQ.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE8 FF3 Op10 Sf4 Cr4
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.