using javascript with php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gupta4net
Forum Newbie
Posts: 2
Joined: Thu Nov 17, 2005 2:58 am

using javascript with php

Post by gupta4net »

Hello,

I am a php developer ,I have a problem with my code can any body will help me.

What I want to do?:

I have two selection box.
1.country
2.state

When I select a country from country selection box without press any buttons( using onchage event), only related states to the country will be displayed on state selection box.

I have tried it with onchange event but not success.

I am using MySQL as Database and PHP as SCRIPT Language.

I have two tables country_master,state_master on MySQL .

Please reply me as soon as possible...
Thanks
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

What you're asking for is called a "linked select", or sometimes a "chained select". There's plenty of tutorials/articles about them if you're after something completely clientside. However, what I usually do is put 'onChange="formname.submit();"' into the select box attributes .. then the form will be submitted on a change enabling me to generate a new set of options for the next select box. It's a bit more intensive on the server, but affords much more control over how it all works.

Alternatively it should be possible to roll an Ajax solution..
Post Reply