• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Javascript and PHP

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can anyone give suggestion how to do that?
thanks
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look up Ajax double combo or linked selects.

Eric
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you were using jQuery it is as simple as



And you php page would just return back



Eric
 
Maya Naga
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shouldn't



be



Eric
 
Maya Naga
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks eric..
i solved this problem by just giving document.form.submit();
its just works fine....
 
reply
    Bookmark Topic Watch Topic
  • New Topic