Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Javascript test for a null Apex field

DougSep 12 2011 — edited Sep 18 2011
Here is some javascript code for w3schools.com illustrating the valueOf boolean method.

<html>
<body>

<script type="text/javascript">

var vamount = 8
var bool = new Boolean(vamount);
document.write(bool.valueOf());

</script>

</body>
</html>

When you execute this code in the w3schools "try it" area, the result panel shows the bool.valueOf() to be "true."

I want to use javascript in an APEX page to execute a command if a field is not null. First I would assign the value of the field to a variable (in the example below "vamount"). Then I would place that variable in this line ("var bool = new Boolean(vamount)". In the w3schools site, using "document.write(bool.valueOf())" returns "true" in the results panel. So, I assume, the value of bool is true.

The question is how can I execute one command or another depending on the value of bool is true or false.

I've tried the following at the w3schools site, but it does not work:

<html>
<body>

<script type="text/javascript">

var vamount = 8
var bool = new Boolean(vamount);
if (bool.valueOf()) == true
document.write(bool.valueOf());

</script>

</body>
</html>

What can I do to make this work?
This post has been answered by NoGot on Sep 14 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 16 2011
Added on Sep 12 2011
11 comments
3,428 views