if (mandatory<=21) { mandtory++; } gives me an error Object expected in some cases:

R

Ruso

I have this function, which should change a value of the texfield(s)
depending on the radio buttons selection.


function foo(obj) {
if (!array[obj.name]) { flag++; }

if (array[obj.name] != obj.value ) {
array[obj.name]=obj.value;

if (array[obj.name]=='no' && ( array1[obj.name]=='yes' ||
!array1[obj.name] ) ) {
if (mandatory<=21) { mandtory++; }
document.form1.ManProNuErr.value=parseInt(window.document.form1.ManProNuErr.value)
+ 1;


array1[obj.name]=obj.value;
array2[obj.name]='';
alert ("no");
}
if (array[obj.name]=='na' && (array1[obj.value]=='' ||
array1[obj.value]=='yes') ) { mandatory-- ;}

if ((array[obj.name]=='yes' && array1[obj.name]=='no' ) ||
(array[obj.name]=='na' && array1[obj.name]=='no') ) {

if (array[obj.name]=='na') {
mandatory--;
alert ("na");

array2[obj.name]='na';
array1[obj.name]='yes';
document.form1.ManProNuErr.value=parseInt(window.document.form1.ManProNuErr.value)
- 1;
}
else if (array[obj.name]=='yes') {
<b> if (mandatory<=21) { mandtory++; } </b>
document.form1.ManProNuErr.value=parseInt(window.document.form1.ManProNuErr.value)
- 1;
array1[obj.name]=obj.value;
array2[obj.name]='';
alert("yes");

}

}

}

}

document.form1.ManProPrsErr.value=roundit((mandatory-parseInt(document.form1.ManProNuErr.value))/mandatory*100,
2) + '%';
}



So the function works greate if i remove the lines "if (mandatory<=21)
{ mandtory++; } " there are two of them, one is when no is pressed and
another one is when yes is pressed.
And the error i recive is kinda clueless object expected, pointing to
the html line: " <td class="style17"><span class="style9"></span></td>"
But to calcuate the percentage, i need those lines to be able to know
how many 'na's were pressed.

Any1 have any idea??
 
E

Evertjan.

Ruso wrote on 08 nov 2006 in comp.lang.javascript:
So the function works greate if i remove the lines "if (mandatory<=21)
{ mandtory++; } " there are two of them, one is when no is pressed and


if (mandatory<=21) { mandtory++; }

because mandatory and mandtory are not the same variable name.
 
R

Ruso

Evertjan. said:
Ruso wrote on 08 nov 2006 in comp.lang.javascript:



if (mandatory<=21) { mandtory++; }

because mandatory and mandtory are not the same variable name.

DAMN!!!!!! DAMN!!!!!
I spend about an hour on this stupid thing. How can I be so stupid. :(

Thanks a lot man!!!
 
R

Randy Webb

Evertjan. said the following on 11/8/2006 11:12 AM:
Ruso wrote on 08 nov 2006 in comp.lang.javascript:



if (mandatory<=21) { mandtory++; }

because mandatory and mandtory are not the same variable name.

if (mandatory<=21){mandatory++}

might work better :)
 
R

Ruso

When i get it work with your help guys, i realized that this approach
does not suit my needs, so I switched to the array based approach.

Anyways, thanks a lot for your quick and helpfull help :)
 
D

Dr J R Stockton

Wed said:
if (mandatory<=21){mandatory++}

might work better :)

Or mandatory += mandatory<=21

Did you watch the Transit of Mercury this evening, not visible from here
for two reasons?
 
R

Randy Webb

Dr J R Stockton said the following on 11/8/2006 6:23 PM:
Or mandatory += mandatory<=21

Did you watch the Transit of Mercury this evening, not visible from here
for two reasons?

No. To be honest, I didn't know it was happening and now it has passed
for me. I guess I will have to wait for NASA to post video of it. You
have to tell me about these things *before* they happen :)
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top