oi, don't be skipping over my answers :p lol

Rick Faircloth wrote:

And finally, to continue today’s live, public coding experiments…

The answer appears to be that a second set of ‘ ‘ are needed for the conditional:

>’ (row[19] ? ‘ ‘ + row[19] + ‘ ‘ : ‘N/A’) + ‘<

Instead of:

>’(row[19] ? ‘ + row[19] + ‘ : ‘N/A’) + ‘<

The first way works with both Boolean and null checks, whereas the second

way works properly only with Boolean.

Sorry to use up to much list-time to answer my own questions, but hopefully

this will help someone as an “impromptu tutorial”…

Rick

*From:* jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] *On Behalf Of *Rick Faircloth
*Sent:* Tuesday, August 11, 2009 11:18 AM
*To:* jquery-en@googlegroups.com
*Subject:* [jQuery] Re: How to specify a default value...

Well..another unexpected result…

When the inline conditional:

>’ + (row[19] ? ‘ + row[19] + ‘ : ‘N/A’) + ‘<

is used when a **value is present** in row[19], I get this as the output:

+ row[19] +

instead of the actual value.

If I remove the quotes from ‘ + row[19] + ‘, I get a syntax error.

However, if **no value is present** in row[19], I get

N/A

as the output, which is expected.

So, the conditional is working if no value is present, but outputting the literal string

+ row[19] +

if a value is not present.

Assistance in understanding, anyone?

Thanks,

Rick

*From:* jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] *On Behalf Of *Rick Faircloth
*Sent:* Tuesday, August 11, 2009 11:00 AM
*To:* jquery-en@googlegroups.com
*Subject:* [jQuery] Re: How to specify a default value...

Well…to answer my own question…I found this works:

out.push('<li><span class="spanLeft">Pet Deposit</span><span class="spanRight">' + (row[19] ? ' + row[19] + ' : 'N/A') + '</span></li>');

But how does the conditional know whether a Boolean is being checked, as in:

>’ + (row[19] ? ‘Yes’ : ‘No’) + ‘<

Or whether the presence of a value is being checked, as in:

>’ + (row[19] ? ‘ + row[19] + ‘ : ‘N/A’) + ‘<

What’s the logic that’s occurring behind the statements to differentiate?

Thanks for any insight…

Rick

*From:* jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] *On Behalf Of *Rick Faircloth
*Sent:* Tuesday, August 11, 2009 10:39 AM
*To:* jquery-en@googlegroups.com
*Subject:* [jQuery] How to specify a default value...

I was shown how to use this inline condition for creating yes/no Boolean values instead of

the normal true/false values javascript uses:

<span class="spanRight">' + (row[20] ? 'Yes' : 'No') + '</span>

I’d like to know if there’s an equivalent inline method for providing a default value

when no value is present, such as:

<span class=”spanRight”>’ + (row[20] ? ‘NORMAL ROW[20] VALUE’ : ‘N/A’) + ‘</span>

Basically, if there’s no value in the current row as position 20, then just us ‘N/A’.

Is this possible with a simple inline condition, too?

Thanks,

Rick

----------------------------------------------------------------------------------------------------------------------

/"Ninety percent of the politicians give the other ten percent a bad reputation." - Henry Kissinger/


Reply via email to