Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP function call with onchange?

Status
Not open for further replies.

sylve

Programmer
Jan 18, 2005
58
CA
This is rather hard to explain. I have a table that looks like this model:

myTable: id, program

A <SELECT> contains all the IDs and I put a hidden tag for program. Ideally, when you select a id, it starts a onchange procedure and program will update via a query:

"SELECT program FROM mytable WHERE id = $id"

I have no idea how to work javascript to doing mysql queries. Does anybody know what would be the best way to get around to doing this?
 
You can't access PHP functions from the client.

JavaScript runs on the web browser, PHP runs on the web server.

What you can do is use the JavaScript onchange() event to programmatically submit the form of which the dropdown is an element. The PHP script to which the form is submitted can then display more data based on the id selected.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
First, thank you for your reply.

"What you can do is use the JavaScript onchange() event to programmatically submit the form "

How would i do that? Can i refresh my form this way perhaps?

My other ida is if i did a mirror array of programs and try to use that? I could then pass this.selectedIndex to the javascript and find the corresponding $programs...

Problem is, i tried and can't seem to pass the array to javascript.
 
I don't understand what you mean by a "mirror array of programs". Once the browser has fully rendered an HTML page, there is no network connection between the two. The browser basically has a snapshot of data which was sent by the server, and there is no connection between the two any more.

I think you would be better served asking JavaScript questions in the JavaScript forum (forum216)

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top