Search the web
Sign In
New User? Sign Up
phpresource · Storehouse of PHP Resources
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Link of the day [24/01/2006]   Message List  
Reply | Forward Message #31 of 2747 |
Re: [phpresource] Post From Mani VY

 
Dear Mani Bhai.
 
You can do it easliy by using AJAX. Whenever you select a division from dropdown, an asynchronous request with that division-value can be sent to your server program (responsible for returning related district list). Again, from the district list you can send asynchronous request same way (as previous) to get the related upazillas. And submitting all these data to your form, you can do your desired operation.
 
Here's a sample code to get and show a one dimensional select-to-select options. I used cpaint framework of AJAX.
 
/*  PHP File -- test.php */
<?php
require_once('you\\path\\ajax\\cpaint.inc.php');
?>
 
<script language="JavaScript" src="ajax/cpaint.inc.js"></script>
<script language="JavaScript" src="test.js"></script>

<form name="test_form" action="test.php" method="POST">
 
<select name="sel0" OnChange="selFn();">
<option value="-1">Select One</option>
<option value="0">Programming</option>
<option value="1">Scripting</option>
</select>
 
<select name="sel1" id="sel1" onChange="showAlert(this.value);">
 <option value="-1">Select One</option>
</select>
  
</form>
 
<?php
 
//Function for returning languages specified by ID
 
function SelectLangs($sel){
 
  mysql_connect("localhost","root","");
  mysql_select_db("test");
 
  if($sel==0)  
  $q="SELECT * FROM langs ORDER BY lang_name";
   elseif($sel==1)
    $q="SELECT * FROM langs WHERE lang_name LIKE 'P%'";
    else
     return "nothing";
  $res=mysql_query($q);      
 
  $i=0;
  $arr=array();
  while($r=mysql_fetch_array($res)){
   $arr[$i++]=$r[lang_name].",";
  }
    $str=implode('',$arr);
   
    $fp=fopen('test8.txt','w');
    fwrite($fp, $str, strlen($str));
    fclose($fp);
   
    return $str;
   
  } //End of function
 
?>
  
/* End of PHP File*/ 
/*  JS File -- test.js */
 
var cnt = 0;
 
function selFn(){
    
    remRows(document.test_form.sel1);
    
    var sel0=document.test_form.sel0.value;                                          
    cpaintCall('SELF', 'POST', 'SelectLangs', sel0, checkLangCallBack);
  }
 
//Callback function
  
function checkLangCallBack(arr){
       
    var aa=new Array();
    aa=arr.split(",")
   
    for(i=0 ; i<aa.length-1 ; i++)  
    {  
      add(aa[i]);
    }
    
  }
 
 
 function add(ele)
 {
  
        newOption = new Option (ele, ele);
        document.test_form.sel1.options.add(newOption);
 cnt++;
 }
    
/* End of JS File*/ 
 
You can get nice AJAX help from here:

Shimul <shimul39@...> wrote:
Dear all,

I have a problem. Let's say I select a division of Bangladesh from a combo/list box. All districts of that division selected in the next list box. Then if I select a district from that list box all upo-zilla (8/9/10 upa-zill) comes and I make a loop to display their name in a combo box. Each combo has a text box to get the population for each upo-zilla. I give some data in the population text box. After giving all population data and selecting associating upo-zilla then I click submit. Now I want to insert all these upo-zilla id and population in the detail table. Actually I want a VB data grid by PHP.

Thank you in advance.

Md. Abul Ahsan (Mani)

Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new and used cars.


Do you Yahoo!?
With a free 1 GB, there's more in store with Yahoo! Mail.

Thu Jan 26, 2006 3:39 am

rupom_315
Offline Offline
Send Email Send Email

Forward
Message #31 of 2747 |
Expand Messages Author Sort by Date

Visit the link below. It's a center of all Open Source CMS resource info. http://www.opensourcecms.com/ Happing PHPing !! [Rupom]...
MA Razzaque Rupom
rupom_315
Offline Send Email
Jan 25, 2006
4:09 am

Dear all, I have a problem. Let's say I select a division of Bangladesh from a combo/list box. All districts of that division selected in the next list box....
Shimul
shimul39
Offline Send Email
Jan 25, 2006
9:59 am

Dear Mani Bhai. You can do it easliy by using AJAX. Whenever you select a division from dropdown, an asynchronous request with that division-value can be sent...
Rupom
rupom_315
Offline Send Email
Jan 26, 2006
3:41 am

Dear Mani Bhai. You can do it easliy by using AJAX. Whenever you select a division from dropdown, an asynchronous request with that division-value can be sent...
Rupom
rupom_315
Offline Send Email
Jan 26, 2006
3:41 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help