Force reload of a SPA page

I have a problem with a SPA child page. On this page I have a form that has a hidden field populated with a variable. This variable is a random 9 digit number. This all works very well. Except the page never gets reloaded to generate a new random number in the variable. I need this number to change each time the form is displayed.

I have tried adding the random number generation as a variable and as a default value for the form field. Even tried clearing the form on submit but the value never changes.

How can I either reset that variable on submit or force a reload of the child page with the form?

Hi Brad,
How are you generating this random number, and how/where is it used?

In the Server Action for insert rather then using your random number select the hidden input and select cryptographic from the formatter and select timestamp and select the same for the salt. Truly random input will be generated and inserted… :wink:

1 Like

I have tried as a variable and a form default value.

<?php echo(rand(100000000,999999999)) ?>

I require it to be a nine digit number. It's eventually used as a membership number.

The php code gets executed on the server Brad, i.e. when the page reloads on the server.
SPA pages don’t get reloaded on the server, but on the clientside. Better generate this on the server side instead of in a hidden field.

Yes, that is exactly my issue, @Teodor. How would I generate it server side?

Sorry Brad, would give you a 9 digit code but would be random characters. Maybe a way to format this in to numbers?

Should it really be 9 symbols and only numbers Brad? Using a 32+ chars hash would be more suitable for unique client IDs.
What if your php code generates the same number, chances for this to happen for 9 digits number are quite higher than a 0 to 9 + A to F hash values.

32 characters is a lot to remember. It’s a number that gets printed on the client’s ID card. A 32 digit hash would not be very practical.

If I was to use a 32 character hash how would I go about adding that on the server side?

I do a already exists validation on the server action. It's never come up with a duplicate in all the years we have been using that method.

In the end we have decided that using @Dave 's suggestion is the way to go. Thanks guys, although the original question didn't get answered this is a viable solution. I learned something too. :wink:

1 Like

@brad, have you thought about generating the random number in mysql instead of php?

I ask because if you could do it that way, you could run a server connect on the page to fill in the form and have it loaded on the page each time the form is loaded. And you could set the Action Scheduler to reload the server connect after a certain time period.

Thanks Scott, I believe we tried that method in our early days. There was some reason that didn’t work. If I recall correctly there was no way to control the number of digits.