View Full Version : Is this possible with strictly Javascript?

05-13-2009, 10:23 PM
We have a client asking for a particular feature for their website. We have to stay client-side because we are implementing a CMS for client updates. This system knows only HTML/XHTML/CSS/Javascript and .Net for forms. We cannot reference ASP(X), PHP or any other server-side language.

What it has to do...
A user will fill in a basic form with their name/number/and email. It will redirect to a popup with a prescription card displayed. There will be 3 static numbers that do not change (displayed on every card) and 1 number that is generated based on the "next in line" number pulled from somewhere. Numbers are between 5,000,000 and 6,999,999.

The trick...
I do not think this is completely doable because the "next in line" number must be pulled from somewhere ALSO updating the database somewhere noting this number can no longer be used.

What server-side languages would be most appropriate for this? I am not a software engineer or computer science engineer so recommending something at this point hasn't been possible.


Old Pedant
05-13-2009, 11:32 PM
I give up, if this paqe is generated via ASP.NET, then why can't you use ASP.NET coding to generate the "next number"??

Your statement is self-contradictory: [quote]...and .Net for forms. We cannot reference ASP(X), PHP or any other server-side language.[/code]
You *ARE* referencing some server side "language" (actually, a platform...as ASP.NET could be VB or C# or ...) if you use ".Net for forms."

Do you mean if the user fills in the form twice/pushes the button twice then they should get *DIFFERENT* numbers?? Suppose they close the popup by accident and want to get it back: You mean that when it reappears it should have a different number?

Why not just assign the numbers in the ASP.NET code as the page is generated???


Having said all that: You could certainly use AJAX to hit some (very lightweight) server page that returns you the next number. If you sent something that identifies the person who filled in the form, then you could even ensure they'd get the same number.

Oh...and it really would not matter, at all, how that AJAX page is written: PHP, JSP, ASP, ASP.NET, whatever. But since you are an ASP.NET shop, it would make most sense to use ASP.NET. Absolutely trivial to do.

05-14-2009, 03:34 PM
My apologies for being confusing with the statement. The CMS app does not understand any code outside of HTML, CSS, Javascript. Please ignore the .Net comment.

I think the only solution is to setup some sort of database (SQL/Oracle etc). Otherwise if there was a way to do it only with Javascript feeding from a .txt file etc you would likely run into data collisions because there wouldn't be any access control. And in return the "system" would likely crash or two users would end up with duplicate numbers.

Again, my apologies. This is a very confusing system they want into place. I can only think of it like a bank. You press submit on getting a new card. The next available generated number is chosen from a database then applied to the user and marked off the list. And the banks have an "access control" on server end to control the "hits" coming in. Therefore, a number is not given away twice.

Old Pedant
05-14-2009, 08:47 PM
So AJAX is the obvious answer.

The server-side code for the AJAX request can be written in any server-side techinique, but ASP.NET works fine.

It's really trivial to do something this simple. The ASP.NET page will only be a couple of dozen lines of code.