2

I m doing a database project using jsp and javascript and back-end using mysql.

In my GUI,there is a page where when i select a particular item in a textbox .the other textboxes should automatically load other values from the database using the value selected from the first textbox.how can i do this using javascript?

I tried using

obj1=this.options[this.selectedIndex].myvalue

But this did not work.

4 Answers 4

2

In this case your Javascript is running at the client end (Browser). It has no programmatic access to the server. The DB operations can be performed by your Java code and the results can consumed by the Javascript. So what you need is an Ajax call to the server, retrieve values from database, construct a JSON response and return it to the client.

Sign up to request clarification or add additional context in comments.

1 Comment

how to call a server using ajax..Any tutorials please
1

javascript is a client-side scripting language .You should use AJAX for access data from Mysql Server.

javascript is used in AJAX to connect to databases. So what you need is an Ajax call to the server, retrieve values from database.

Refer : http://www.ajaxmatters.com/2006/05/getting-started-with-ajax-using-java-tutorial/

Comments

0

use ajax to make a server call that will retrieve the values from the database.Its not possible in Javascript alone.

2 Comments

Can u send me any tutorials or documents or sample codes for this.
0

Javascript is processed by the web browser, and as such doesn't have direct access to your web server as it is done after the user has received the data from your server.

To do as you wish you need to use a server-side language (in your case java as you stated your page is a .jsp)

If you are really dead-set on doing this in Javascript, then node.js may be of assistance, check out http://nodejs.org/ and http://net.tutsplus.com/tutorials/javascript-ajax/learning-serverside-javascript-with-node-js/ however seeing as you are using java to generate your pages this is a bit overkill.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.