Click here to Skip to main content
15,885,915 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a dropdown box in my html body along with two textboxes. The values in Dropdown box is fetched using sql query. I want to autopopulate the textboxes which are 2 in number with related values of the database table whose value I am getting in the dropdown upon selection. Is it possible in Javascript or Ajax or jquery? Kindly help me with code as I am new to these languages?

What I have tried:

I have a dropdown box in my html body along with two textboxes. The values in Dropdown box is fetched using sql query. I want to autopopulate the textboxes which are 2 in number with related values of the database table whose value I am getting in the dropdown upon selection. Is it possible in Javascript or Ajax or jquery? Kindly help me with code as I am new to these languages?
Posted
Updated 16-Apr-20 4:23am
Comments
F-ES Sitecore 16-Apr-20 8:38am    
Yes it is possible but your question is essentially "how do I make a website". You say the data comes from a sql query so that will be server-side processing but you haven't said what server-side tech you are using so this is impossible to answer. If I was you I'd start with hard-coded data server side to make it easy, then change to sql queries once that is working. You'll need to use ajax to call a web method of some sort, so choose your server-side text and google how to call it via ajax for examples.

1 solution

The most sensible way to do this is AJAX. I don't bother with jquery - using straight javaScript, php, etc.

Here's your AJAX reference (from where I learned it).

AJAX Introduction[^] This makes it pretty straight forward and has examples. Simple examples.

One thing: "new to these languages" is not particularly informative. I cannot tell if you're in over your head or not. I'll presume you created the initial query to populate the droplist. If not - you need to back up and learn how to do that own your own.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900