Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes HTML, CSS and JavaScript and the fly likes Javascript and PHP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Javascript and PHP" Watch "Javascript and PHP" New topic
Author

Javascript and PHP

Maya Naga
Ranch Hand

Joined: Nov 09, 2009
Posts: 79
hi ranches....

this may be a simple problem but am stucked how to proceed forward since am new to php and javascript...
i need to use selected value from the list box as a condition to a mysql query..
for example, i have database as follows

+----------------+----
| Name | Number |
+---------------+----
| sun | 3882
| sun | 3888
| sun | 3899
| ram | 3053
| ler | 3233
| ler | 3321
| ler | 3323
| sam | 3677
| joe | 3766
| scs | 3688
| kris | 3044

am just making a list box which consists of above names...
now when the user selects any of the name then i want the text box to be automatically filled by the numbers related to tat names...
i have tried below code. but i don know how to pass the selected value to next query which fetches the number..


can anyone help me giving some idea or sample code??

thank you.

Maya Naga
Ranch Hand

Joined: Nov 09, 2009
Posts: 79
can anyone give suggestion how to do that?
thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Look up Ajax double combo or linked selects.

Eric
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
If you were using jQuery it is as simple as



And you php page would just return back



Eric
Maya Naga
Ranch Hand

Joined: Nov 09, 2009
Posts: 79
hi ,
i have solved getting the selected combo value and passing it to another mysql query. am getting the result.
but now i need to pass these values to textfield.
here is my code;



actually this is a part of my application. my home page code would be as follows:




can anyone help how to pass the result value to textfield...[is it possible without using ajax]
thanks in advance.
Maya Naga
Ranch Hand

Joined: Nov 09, 2009
Posts: 79
hi ranches...

my doubt is whether we can pass the query result '$no' directly to javascript variable to fill in the textbox using onchange() function. i dono how to pass this value. i tried the below code but its not working. please someone say how to proceed. i need the query result value to be displayed in textfield when user selects item from combobox.

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Shouldn't



be



Eric
Maya Naga
Ranch Hand

Joined: Nov 09, 2009
Posts: 79
thanks eric..
but when i used to pass the variable $total_numbers through onchange function, the alert results as "hi undefined"...
how to pass the result value $total_numbers to textbox through onchange function.. here is my code which shows result in textbox when submit button is cliked..
please is any other way to solve this?



Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Sounds like you are mixing up php and JavaScript. The php code will not run once the page has been completely rendered.

If you want to pass the selected value with JavaScript it would be just


Eric
Maya Naga
Ranch Hand

Joined: Nov 09, 2009
Posts: 79
thanks eric..
i solved this problem by just giving document.form.submit();
its just works fine....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javascript and PHP
 
Similar Threads
google adsense tracker
Passing values between PHP pages without navigation
Using javascript with PHP
Pagination Problem
Submit dynamically created form with jQuery