When you submit the form, it checks whether the seed field has an empty string if the field has a value. ColdFusion installs a cryptography library with the following. The algorithm to use to generate the random number. And are you generating the answer list from a query? This will still work, but depending on how you use the query afterwards, you probably wouldn't want to use shuffle() directly on the query object. Generates a pseudo-random integer in the range between two specified numbers. Also, Java Collection.shuffle() will work with Structs. I want to avoid duplicate entries when creating new records in the table, but Im not sure how to set it up correctly. Note 2: Depending on what you want to do with the list, it may be much easier to leave your shuffled answers in an Array object and work with that. Im running Coldfusion8/MySQL 5.0.88 and have table with ids, which are random strings a-z 0-9. This form allows you to generate random text strings. Note 1: Java shuffle() operates directly on its input array, so you are actually changing the array itself. You’d then use that random string in every instance of the CSRFGenerateToken() function call in your application. CF works very well with Java, especially for these types of manipulations. This works because ColdFusion Arrays are automatically also Java Arrays. With large lists, I believe it can be much more inefficient than building out a randomizing function to shuffle the list. Since you're working with small lists, Java's shuffle() should be pretty quick. RandomAnswerList = ArrayToList(answerArra圓) Output our shuffled array (as an array). Example : Generating a Random Password In this example, you'll learn how to build up a string rather than break down one. What is Coldfusion 10 random number generation best practice >sha1prng: generates a number using the Sun Java. Since // theres no 'correct' way to generate a byte array in ColdFusion, we can // generate a string of the desired length and then decode it into bytes. If you are looking to return a randomized list of answers, you can use Java Collections to interact with your ColdFusion list (after turning the list into an array). I know I can do it with numbers easily, but I have a preference for unique answer ID in text) - works only once It doesn't work.Īny thoughts folks? Or is there an easier way to do this. If I reload page it doesn't randomize again.Īlso - if it is a True False Answer of only 2 choices. Using a unique ID (Text) - Below randomizes the list only once when I use it. I'm trying to create random test answers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |