/    Sign up×
Community /Pin to ProfileBookmark

Database query in javascript

I am dynamically generating a select element using javasript and DOM methods. There are a couple of text fields in my form and what I need is that according to the option that user chooses in the select the corresponding fields should get populated from the database. For that I tried setting the select.onChange = somefunction but am not to sure how can I obtain the values from the database. How do I connect to the database in javascript. For sample I will enclose the code

[CODE]<script type=”text/javascript”>
function Change()
{
// How do I fetch the database values from the javascript??
}
function Select()
{
var select1= document.createElement(‘select’);
select1.setAttribute(‘name’,’company’);
select1.setAttribute(‘id’,’azcompany’);
select1.setAttribute(‘size’,’1′);
select1.style.position = ‘absolute’;
select1.style.left = ‘250px’;
select1.style.top = ‘225px’;
select1.style.width = ‘250px’;
select.onChange = javascript/change(); //Please not I am unfamiliar with the synatax but this is what I want to do
[/CODE]

Is there some other way that I can do this ?

Thanks in advance

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@FangSep 14.2007 — How do I connect to the database in javascript.[/QUOTE]
You can't; a server side language is necessary.
Copy linkTweet thisAlerts:
@ruchi_bhindwaleauthorSep 14.2007 — What can I use for that and can you please suggest how can I do that ?

Thanks
Copy linkTweet thisAlerts:
@DokSep 15.2007 — Use PHP, ASP, JSP or similar.
Copy linkTweet thisAlerts:
@Angry_Black_ManSep 16.2007 — You can't; a server side language is necessary.[/QUOTE]

that is incorrect. however, this method requires activex controls and would be mostly ineffective unless utilized in a controlled environment.
Copy linkTweet thisAlerts:
@FangSep 17.2007 — that is incorrect. however, this method requires activex controls and would be mostly ineffective unless utilized in a controlled environment.[/QUOTE]
ActixeX only works in IE and requires user permission.

Fx has it's own method which also requires user permission.

As a general case you will need a server side solution.
×

Success!

Help @ruchi_bhindwale spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...