Child question + illegal start of expression error

C

cliveswan

I have a form with a question and child questions

eg q1 program - Yes/no
q2 web; desktop
q3 java; .net; #C

My form is:
Q6a: Waterproblem (yes/NO)
Q6b: Current - radiobutton (curent, 1-5 years)
Q6c: Location Home (yes/No); Garden (Yes/No); common (yes/no)

If user selects Q6a = Yes (1)
.....
Q6c Home (0/1); Garden (0/1); common (0/1)

I want to check, if user selects Yes for Q6a, then they need
select 1 from Q6c.
If they don't select one choice, want to have a simple error warning.

Yes = 1 No = 0

The code shows an illegal start of expression error????
if( page8.getWasteWaterProblem() == 1 ) ||
(getWasteWaterLocationProblemHome() == 0) ||
(getWasteWaterLocationProblemGarden() == 0) ||
(getWasteWaterLocationProblemCommonArea() ==0){

validationResultPage8.addWarning("WasteWaterProlemHome", "warning for
WasteWaterProlemHome from type 6c");
}
 
E

Eric Sosman

I have a form with a question and child questions

eg q1 program - Yes/no
q2 web; desktop
q3 java; .net; #C

My form is:
Q6a: Waterproblem (yes/NO)
Q6b: Current - radiobutton (curent, 1-5 years)
Q6c: Location Home (yes/No); Garden (Yes/No); common (yes/no)

If user selects Q6a = Yes (1)
....
Q6c Home (0/1); Garden (0/1); common (0/1)

I want to check, if user selects Yes for Q6a, then they need
select 1 from Q6c.
If they don't select one choice, want to have a simple error warning.

Yes = 1 No = 0

The code shows an illegal start of expression error????


if( page8.getWasteWaterProblem() == 1 ) ||
^

The test portion of the `if' statement ends at
this parenthesis. What follows should be an executable
statement, but what actually follows is `||'. `||' is
not valid as the start of an expression or statement.

Possible cure: Delete that parenthesis. Alternative
cure: Insert an opening parenthesis just before `page8'.
Either way, you will also need to add another closing
parenthesis just before the `}' below.

Still another cure: Get rid of all the parentheses
except the one right after `if', the one right before
`}', and the pairs after each method call.
(getWasteWaterLocationProblemHome() == 0) ||
(getWasteWaterLocationProblemGarden() == 0) ||
(getWasteWaterLocationProblemCommonArea() ==0){

validationResultPage8.addWarning("WasteWaterProlemHome", "warning for
WasteWaterProlemHome from type 6c");
}

Note, too, that the logic is flawed: The test (after
correction) will produce a validation warning if the
first box is checked or if any of the others is unchecked.
From your description, I doubt that's what you want.
 
L

Lew

Note, too, that the logic is flawed: The test (after
correction) will produce a validation warning if the
first box is checked or if any of the others is unchecked.
From your description, I doubt that's what you want.

Also note that multi-posting causes people to answer your questions without
knowledge of each other's answers and is very rude, as it makes those of us
who try to help feel that you have taken advantage of us and caused us to
waste our time.

Please do not multi-post.
 
C

cliveswan

Hi,

This is a different question from the previous.
It is looking at validating a question & connected child question
in a row!!!

I tried to write a bit of code THAT does not work.
Trying to understand why!!

Clive
 
C

cliveswan

Hi eric & Lew,

Am I still not getting the 'logic'

Trying to say:

if a = 1 and ( (b + c + d ) = 0 ){
Then throw a warning
}

if( page8.getWasteWaterProblem() == 1 ) &&
( ( (page8.getWasteWaterLocationProblemHome() ) +
(page8.getWasteWaterLocationProblemGarden() )
+ (page8.getWasteWaterLocationProblemCommonArea()) == 0) ) {
validationResultPage8.addWarning("WasteWaterProlemHome", "warning
for Q6c");
}
This still says "illegal start of expression"??????
I do not understand why.

Cheers

Clive
 
C

Clive

(e-mail address removed) wrote On 04/16/07 16:51,:


Also note that multi-posting causes people to answer your questions without
knowledge of each other's answers and is very rude, as it makes those of us
who try to help feel that you have taken advantage of us and caused us to
waste our time.
I popsted it here by mistake.

You are not able to delete a question, posted by mistake.

Clive
 
C

Clive

(e-mail address removed) wrote On 04/16/07 16:51,:


Also note that multi-posting causes people to answer your questions without
knowledge of each other's answers and is very rude, as it makes those of us
who try to help feel that you have taken advantage of us and caused us to
waste our time.
It would be useful, if the list had an option to delte questions, sent
to the wrong
newsgroup!! This was meant for developers NOT database
 
C

cliveswan

(e-mail address removed) wrote On 04/16/07 16:51,:


Also note that multi-posting causes people to answer your questions without
knowledge of each other's answers and is very rude, as it makes those of us
who try to help feel that you have taken advantage of us and caused us to
waste our time.




I FINALLY saw each argument must be within ( ). That went over my
head.

This ran without any errors.

BUT does it actually do what is says: ( (a=0 + b=0 + c=0) and (d =
1) )
then throw warning?????

Cheers

Clive

if ( ( page8.getWasteWaterLocationProblemHome() == 0 &&
page8.getWasteWaterLocationProblemGarden() == 0 &&
page8.getWasteWaterLocationProblemCommonArea() == 0) &&
( page8.getWasteWaterProblem() == 1) ) {

validationResultPage8.addWarning("WasteWaterProlemHome", "warning
for WasteWaterProlemHome from type 6c");
}
 
C

cliveswan

I FINALLY saw each argument must be within ( ( ) && ( ) ). That went
over my head.

This ran without any errors.

BUT does it actually do what is says: ( (a=0 + b=0 + c=0) and (d =
1) )
then throw warning?????

Cheers
Clive


if ( ( page8.getWasteWaterLocationProblemHome() == 0 &&
page8.getWasteWaterLocationProblemGarden() == 0 &&
page8.getWasteWaterLocationProblemCommonArea() == 0)
&&
( page8.getWasteWaterProblem() == 1) ) {



validationResultPage8.addWarning("WasteWaterProlemHome", "warning
for WasteWaterProlemHome from type 6c");
}
 
L

Lew

I FINALLY saw each argument must be within ( ( ) && ( ) ). That went
over my head.

<http://java.sun.com/docs/books/tutorial/java/nutsandbolts/if.html>

They aren't arguments, they're conditions.
This ran without any errors.

BUT does it actually do what is says: ( (a=0 + b=0 + c=0) and (d =
1) )
then throw warning?????
(You only need one question mark to signify a question.)

I am confused. It ran without errors or it threw a warning?

To answer your question, code always does what it says. It just might not do
what you think.
if ( ( page8.getWasteWaterLocationProblemHome() == 0 &&
page8.getWasteWaterLocationProblemGarden() == 0 &&
page8.getWasteWaterLocationProblemCommonArea() == 0)
&&
( page8.getWasteWaterProblem() == 1) ) {



validationResultPage8.addWarning("WasteWaterProlemHome", "warning
for WasteWaterProlemHome from type 6c");
}

If you have a question, please provide an SSCCE and copy-and-paste (do not
describe) the error message, and ask the question.

You should also follow standard indentation conventions; your code snippet is
not formatted for readability.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top