Current location: Hot Scripts Forums » General Web Coding » JavaScript » Need Help for Javasript and PHP


Need Help for Javasript and PHP

Reply
  #1 (permalink)  
Old 09-19-05, 06:46 AM
jaishalg jaishalg is offline
Newbie Coder
 
Join Date: May 2004
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Need Help for Javasript and PHP

Hey all....
i have a problem
i had a dropdown menu in which i had taken name of the counties from the database (dynamic dropdown) using PHP and mysql

now i want that when user select a country it will shows only the states which belongs to the same country.

i know this is happens with the onChange using JAVASCRIPT, but i dont know how to do this...
both the drop down menu is dynamic...
when user select country, he/she had fill up some information that should not go when the page refresh...
i m really not good with JAVASCRIPT, can anyone help me for the same
a little help will be good for me.
Reply With Quote
  #2 (permalink)  
Old 09-23-05, 05:27 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
I think you could get the best looking effect by using a technique referred to as AJAX.
It's a combination of serverside languages and Javascript which relies upon the xmlHttpRequest feature. It allows you to request data from the server (it doesn't have to be xml) at any time without reloading the page. The Javascript sends some information (in your case the selected country) when the onchange event fires as you mentioned. The server handles the data and sends back the states as a list separated by some special character(s). The JavaScript is notified that the data has been retrieved and clears the state-dropdown-list. It then slices up the datastring and populates the list with new options.

The 'oldschool' way of doing this could involve a hidden frame which had its URL updated by Javascript. That way you can send along a querystring. When the data is sent back from the server, the hidden frame is updated instead of the whole page.
The server also sends along a small script (maybe just a single command) which notifies the main script that the data in the hidden frame has been updated.

I'm sorry but I don't have a good example of how to do this, but try searching for AJAX, or using hidden frames to request server data.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #3 (permalink)  
Old 10-26-05, 03:51 AM
mouse_whisperer mouse_whisperer is offline
Newbie Coder
 
Join Date: Oct 2005
Location: UK
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
In case it helps, I have an introductory Ajax tutorial on my website at www.mousewhisperer.co.uk/ajax_page.html
__________________
The Mouse Whisperer
www.mousewhisperer.co.uk
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 10:17 AM
PHP Downside--Solutions? Amulet PHP 10 07-15-05 08:26 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
PHP / Graphic Developers someotherguy582 Job Offers & Assistance 1 06-05-05 07:40 PM
100 Web Templates & 10 PHP Scripts for sale! HostersUK.co.uk General Advertisements 0 01-10-04 12:31 AM


All times are GMT -5. The time now is 10:54 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.