• Post Reply Bookmark Topic Watch Topic
  • New Topic

javascript database connectivity  RSS feed

 
Rene Curth
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I have to deal with a little problem. In a Combo-Box are displayed a lot of last names, ready for selection. Nearby is an text input field, which is waiting for user entry (also a last name). The javascript function has to detect user action in this input field (e.g. onkeypress) and to update the combobox with names beginning with the characters, displayed in the input field while he (or she) is typing it. The names are stored in a ms sql-server database (more than 7000).
The updating process has to be dynamically. My solution up to this point was to integrate an applet, which contains a swing combo-box. The applet is accessed by an javascript function (onkeypress) and contacts a servlet, doing the sql-job. The servlet returns the result to the applet, which is updating the combo-box. Also it's updating other input text-fields (first name, birthdate) by talking to another javascript function.
I think this solution is very complicated and not very elegant. Is there another way for an javascript function to talk with a server-sided database directly or to put it in other words: is there a way for a javascript function to communicate with a servlet directly?
What about jsp? Is it possible to put jsp-code in a javascript function, doing the job dynamically?
I would appreciate a more elegant way of doing it!
Thanx in advance
Rene
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can NOT execute serverside code from Javascript (or any other clientside technology).

In your javascript, you'll need to call a servlet to generate the data which you can then insert into a span or div (or you need to regenerate the entire page from scratch).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!