JRS: In article <x9*****************@fe01.usenetserver.com>, seen in
news:comp.lang.javascript, Matthew <tu*************@alltel.net> posted
at Tue, 3 Feb 2004 19:37:46 :-
function checkform() {
if (document.cart.qty01.value != 8)
{
return false
}
if (document.cart.qty02.value != 7)
{
return false
}
if (document.cart.qty03.value != 6)
{
return false
}
if (document.cart.qty04.value != 4)
{
return false
}
return true
}
The following should be equivalent; but it seems a strange need :
function checkform() { return (
document.cart.qty01.value == 8 &&
document.cart.qty02.value == 7 &&
document.cart.qty03.value == 6 &&
document.cart.qty04.value == 4 ) }
function checkform() { with (document.cart) return (
qty01.value == 8 && qty02.value == 7 &&
qty03.value == 6 && qty04.value == 4 ) }
To turn off checking by function X, use global G
function X() {
if (G) return true // or false
<series-of-tests> }
function X() {
return G || <series-of-tests> }
function X() {
return G && <series-of-tests> }
The first and second return true if G is true; the third returns false
if G is false; in each case, without further tests. I think.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<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.