filling out textfields using a pulldown to select an mysql databaserecord

R

R.G. Vervoort

I would like to select an option in a pulldown, select a record in a mysql
database depending on the pulldown selection and then put the data from the
record in the textfields.

I can retrieve the pulldown value using javascript

I can open the database and select the record using php

how can i combine the 2 to within the onchange option of the pull down.

Any suggestions welcome because i am getting crazy with this


roy
 
M

Markus Ernst

R.G. Vervoort said:
I would like to select an option in a pulldown, select a record in a mysql
database depending on the pulldown selection and then put the data from the
record in the textfields.

I can retrieve the pulldown value using javascript

I can open the database and select the record using php

how can i combine the 2 to within the onchange option of the pull down.

Any suggestions welcome because i am getting crazy with this

As Javascript runs on the client and PHP/MySQL on the server you have the
following 2 possibilities:

1. After having choosen the pulldown value you submit the form and display
the page again with the value filled into the textfield by PHP.

2. If you don't want to submit the form you have to bring the database
entries to the client side: write the records from MySQL into a Javascript
array with PHP and then get them from there with Javascript.

HTH
Markus
 
P

Pierced Media LC

If I understand properly, you want to use a <select></select> element to
select some given information from a database, but you want to do this
without reloading the page. The short answer is "it can't be done" Once the
page is loaded, it's all there, another HTTP request must be made to run
more processes. If you don't want to reload an entire page you could use an
Iframe/layer.

Hope this helped.
 
T

Thomas 'PointedEars' Lahn

R.G. Vervoort said:
I would like to select an option in a pulldown, select a record in a mysql
database depending on the pulldown selection and then put the data from the
record in the textfields.

I can retrieve the pulldown value using javascript

I can open the database and select the record using php

how can i combine the 2 to within the onchange option of the pull down.

You cannot, unless you want to serve the database data along with the
document that contains the "select" element or (re)load the/a new document,
as Markus pointed out. Retrieval of server-side information requires a
(HTTP) request. If you know your target environment, you may want to use
XMLHTTPRequest. Ask Google (Groups).

Excessive crossposting like this without Followup-To is unwished in Usenet.
Especially comp.lang.java.javascript is IMO obsolete, Java != JavaScript.
Please learn how to post: <http://www.faqs.org/faqs/usenet/posting-rules/part1/>


F'up2 comp.lang.javascript

PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top