Goodwin Posted August 31, 2010 Report Share Posted August 31, 2010 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. Quote Link to comment Share on other sites More sharing options...
skywalker Posted August 31, 2010 Report Share Posted August 31, 2010 You could try this. I havent tested it but might help... var BookNumber: = "[@Book]"; if (BookNumber == ("")) { BookNumber = "All"; } else { Your code.... } Quote Link to comment Share on other sites More sharing options...
Goodwin Posted August 31, 2010 Author Report Share Posted August 31, 2010 Thanks for the reply. I gave it a shot, but it didn't help. Any other ideas? Quote Link to comment Share on other sites More sharing options...
bahar_vm Posted September 14, 2010 Report Share Posted September 14, 2010 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.