tags:

views:

39

answers:

2

Dear all,

am developing a web application and I need some help. I have in my database(MySQL) tables for village linked to the sub county table. Sub county linked to the county table and the county table linked to the District table.

I need to design a web form in dreamweaver using PHP for capturing people's details i.e Name,Date of Birth, Village, Sub county,County and District. But since I'll already have the District,County,Sub county and village in my DB, I need to create a drop down for village which after selection should populate automatically the Sub county,county and district text fields.

You can advise on the best way I could do this.

Cheers.

A: 

A simple query is in order? Just use an ajax request to send the selected country to a script, the script should return either XML data to fill the select box with or send the dom select box.

Ferdi
Would you please explain further how I can do that.Thank u.
moses2010
A: 

i'd go for the

<select onchange="ajaxGetWhatYouNeedByValue(this.value, 'populate some #id');"><option.....

as i understood your question, you need something like => when you select a village it should return all related data associated with the village. Therefore i suggest you using ajax for background loading needed data.

vertazzar
Please attached is my code. Explain how I could embed that in my code or how best I should modify it. Cheers.The code below is for displaying the data in the villages record set.Ihave similar ones for others<select name="Village"> <?php do { ?> <option value="<?php echo $row_rsVillage['Village_Name']?>" <?php if (!(strcmp($row_rsVillage['Village_Name'], $row_rsVillage['Village_Name']))) {echo "SELECTED";} ?>><?php echo $row_rsVillage['Village_Name']?></option> <?php} while ($row_rsVillage = mysql_fetch_assoc($rsVillage));?> </select>
moses2010
you must make javascript function, like i gave example above.You can use jquery to fetch data with ajax,function ajaxGetWhatYouNeedByValue(value, id) { $.ajax({ type: "GET", url: '/ajax-data.php?value='+value, success: function (data) { $(id).html(data); } });}so onchange properity for select html element will fire event "onchange" which calls the js function above, the function will populate the desired id e.g. (<div id="element"></div>) with data. you can return data as you wish. This is as far as i understood your question.
vertazzar
Thank you for the reply.Am trying it out.
moses2010