Page 1 of 1

using javascript with php

Posted: Wed Nov 23, 2005 3:47 am
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

Posted: Wed Nov 23, 2005 4:12 am
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..