I am an old man learning new tricks. I come from asp.net web forms, and so I have a learning curve to MVC5, and little experience in javascript. That being said . . . here is my issue.
Each time a client makes a transaction on the form, I need to create a unique transaction number. I can think of two ways of doing this. One would be to use the unique ID in the table. However, that does not yet exist until the record is submitted from the form to the table. I guess we could query the table for a record count, and then add 1. . . but, the tutorials that involved that (online) seemed overly complicated for what I want to do. Grab a recordcount and pass it in the Viewbag seems simple enough. But I can't find a basic tutorial that does that simply enough.
And so, I moved on to JavaScript to create a random Number. And then pass that value to the appropriate html TextBoxFor. I am almost there . . . but not quite. Here is my JavaScript
var min = 1398799;
var max = 9999999;
var random = Math.floor(Math.random() * (+max - +min)) + +min;
$("#RequsitionNumber").val($("RO"+random));
I am trying to pass the value of 'random' to the object 'RequisitionNumber' What it is passing currently is "[object Object]"
I think the last line of code needs to be different.
I am also open to going back and doing things via controller . . . getting the table row count, and passing it as viewbag . . . . either is okay.