HighDots Forums  

Total newbie question, I'm afraid...

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Total newbie question, I'm afraid... in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mark B
 
Posts: n/a

Default Total newbie question, I'm afraid... - 08-11-2006 , 07:03 AM






Hi,

I'm completely green when it comes to Javascript - I can kind of understand
it, but don't understand the finer logic of it (I'm more an ASP person, a'la
VBScript, VB, etc).

Why doesn't this JS work?

<SCRIPT TYPE="text/javascript">
function FlipFlop(){
if(SearchH.R1.checked)(SearchH.R2.checked=0);
if(SearchH.C5.checked==1)(SearchH.C2.checked=1)(Se archH.C5.checked=0);
if(SearchH.C6.checked==1)(SearchH.C3.checked=1)(Se archH.C6.checked=0);
if(SearchH.C7.checked==1)(SearchH.C4.checked=1)(Se archH.C7.checked=0);
}
function FlipFlop2(){
if(SearchH.R2.checked)(SearchH.R1.checked=0);
if(SearchH.C2.checked==1)(SearchH.C5.checked=1)(Se archH.C2.checked=0);
if(SearchH.C3.checked==1)(SearchH.C6.checked=1)(Se archH.C3.checked=0);
if(SearchH.C4.checked==1)(SearchH.C7.checked=1)(Se archH.C4.checked=0);
}

Essentially, there are two radio buttons on an ASP generated form. If the
user chooses one radio button, the other is deselected. (Onclick call
FlipFlop, or FlipFlop2). This bit works.

Associated with the radio buttons are two groups of three check boxes. The
user can choose any or all of the three check boxes associated with each
radio button.

A nicety would be if the radio button selection changes, the check box
selections should carry to the other group of three check boxes.

This is the bit that only partially works. If any ONE of the check boxes is
checked, the opposite and equal checkbox is checked if the user chooses the
other radio button. Unfortunately, if two or more check boxes are selected,
only the FIRST selected check box's logic is transferred. Any other checkbox
states are ignored.

Like I said - I know veeeery little about JS, and I'll wager the above is
full of errors. Be gentle! Any help appreciated!

Mark



Reply With Quote
  #2  
Old   
Mike Scirocco
 
Posts: n/a

Default Re: Total newbie question, I'm afraid... - 08-11-2006 , 11:06 AM






Mark B wrote:
Quote:
Hi,

I'm completely green when it comes to Javascript - I can kind of understand
it, but don't understand the finer logic of it (I'm more an ASP person, a'la
VBScript, VB, etc).

Why doesn't this JS work?

SCRIPT TYPE="text/javascript"
function FlipFlop(){
if(SearchH.R1.checked)(SearchH.R2.checked=0);
if(SearchH.C5.checked==1)(SearchH.C2.checked=1)(Se archH.C5.checked=0);
if(SearchH.C6.checked==1)(SearchH.C3.checked=1)(Se archH.C6.checked=0);
if(SearchH.C7.checked==1)(SearchH.C4.checked=1)(Se archH.C7.checked=0);
}
function FlipFlop2(){
if(SearchH.R2.checked)(SearchH.R1.checked=0);
if(SearchH.C2.checked==1)(SearchH.C5.checked=1)(Se archH.C2.checked=0);
if(SearchH.C3.checked==1)(SearchH.C6.checked=1)(Se archH.C3.checked=0);
if(SearchH.C4.checked==1)(SearchH.C7.checked=1)(Se archH.C4.checked=0);
}

Essentially, there are two radio buttons on an ASP generated form. If the
user chooses one radio button, the other is deselected. (Onclick call
FlipFlop, or FlipFlop2). This bit works.

Associated with the radio buttons are two groups of three check boxes. The
user can choose any or all of the three check boxes associated with each
radio button.

A nicety would be if the radio button selection changes, the check box
selections should carry to the other group of three check boxes.

This is the bit that only partially works. If any ONE of the check boxes is
checked, the opposite and equal checkbox is checked if the user chooses the
other radio button. Unfortunately, if two or more check boxes are selected,
only the FIRST selected check box's logic is transferred. Any other checkbox
states are ignored.

Like I said - I know veeeery little about JS, and I'll wager the above is
full of errors. Be gentle! Any help appreciated!

Mark

if(SearchH.C5.checked==1)(SearchH.C2.checked=1)(Se archH.C5.checked=0);
I believe it's the case that if you don't use curly brackets after an if
condition then only the next statement is executed

I recommend reading this page:

http://gwydir.demon.co.uk/jo/javascript/if.htm

Mike


Reply With Quote
  #3  
Old   
Mike Scirocco
 
Posts: n/a

Default Re: Total newbie question, I'm afraid... - 08-11-2006 , 11:18 AM



Mark B wrote:
Quote:
Hi,

I'm completely green when it comes to Javascript - I can kind of understand
it, but don't understand the finer logic of it (I'm more an ASP person, a'la
VBScript, VB, etc).

Why doesn't this JS work?
snip

Probably a little clearer:

http://developer.mozilla.org/en/docs...ents:if...else

Syntax

if (condition)
statement1
[else
statement2]

[edit]
Parameters

condition
An expression that evaluates to true or false.

statement1
Statement that is executed if condition evaluates to true. Can be
any statement, including further nested if statements. To execute
multiple statements, use a block statement ({ ... }) to group those
statements.

======================

http://richardbowles.tripod.com/java...n3/lesson3.htm

The condition is a statement which may be true or may be false. If it is
true, the statements inside the { } are executed. If the conditions is
false, the statements aren't executed. Here's an example:

var userInput = prompt("Please enter a number","");
var actualNumber = parseFloat(userInput);
// Remember, the previous statement turns the string into a number
if (actualNumber > 100)
{ document.write("You entered a really big number!");
}

This short program gets the user to enter a number. If the number is
bigger than 100 (actualNumber > 100), then the message is written on the
screen. If the number isn't bigger than 100, then no message appears.

In fact, if the curly brackets after the condition only contain one
statement, as they do in the example above (just the document.write
statement), then you don't really need the curly brackets. I could have
missed them out, and it would have had no effect on the program:


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.