• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Changing variables dynamically

 
Saulo Menezes
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hya!
At the moment I am trying to implement a small web site based on JSP and JavaScript with my group at university.
I have created some JavaBeans which keep information about some artists, the day they are to present a concert, the price of the tickets and how many there are available.
This information is brought back to the user once he makes any choice on his browser. The problem is that the number of tickets available is not changing dynamically. Actually this number is a JavaScript variable that always starts with the value 100.
I wonder how I could make this number change if every time a different user visits the page this number will be set to its first value, 100.
I would be grateful if one of you could give me some advice in this.
Yours,
Saulo
[ May 22, 2003: Message edited by: Saulo Menezes ]
 
Geeta Ramasami
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If u r going to have a javascript variable it will be reinitialised for every browser refresh.
For reflecting the avaliable tickets u can follow 2 approaches.
1.One is after storing the ticket value in the database and after each user visits the site and books the tckt u can update the DB so that each user when chooses to view the available ticktes it would be the correct one.
2.Other is using application variable(putting the number of available tickets in the servlet context).This variable is available for all the users and when each user books a ticket u can update this variable value(ie current value minus 1).If a user chooses to look in for the number of available tckts he would get the current availablity taken from the servlet context.
Regards
Geeta
 
Debashish Chakrabarty
Ranch Hand
Posts: 231
Firefox Browser Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also opt for generating the "javascript" dynamically. The initial value of "100" can be any value (say, incrementing on the last value fecthed from a query on your database). For ex:

HTH
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic