Jump to content

"On exit: Pass field value to next page" + When null (JS)


Recommended Posts

I'm trying to complete a simple Javascript code whereby I test whether a passed parameter is null. However, whenever a value is not supplied by the user, my code doesn't return anything. Here's what I have so far ([@Book] is the Caspio parameter name):

var BookNumber;

if ([@Book]==null)

{

BookNumber = "All";

}

else

{

BookNumber = [@Book];

}

document.write(BookNumber);

If [@Book] has a value, the code works as expected. If it doesn't have a value, the code doesn't work. Any help would be greatly appreciated. By the way, I tried testing for undefined and empty string (""), neither of which helped.

Link to comment
Share on other sites

  • 2 weeks later...

How about this:

<script>
var BookNumber = "[@Book]";

if (BookNumber == "")  {

BookNumber = "All";
}
document.write(BookNumber);
</script>

Also where is [@Book] coming from? And which kind of DataPage you have this code in? For example if you are in update form, details or results page you can read the value of a field using the following parameter: [@field:FIELDNAME]. If this is a parameter you are passing from another web page and receiving in the Caspio DataPage using this name: [@Book] then it is fine.

I hope this helps.

Best,

Bahar M.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...